Skip to content
This repository has been archived by the owner on Jan 5, 2021. It is now read-only.

In high res images, the height and width are fetched in reverse #21

Open
Samigos opened this issue May 12, 2018 · 0 comments
Open

In high res images, the height and width are fetched in reverse #21

Samigos opened this issue May 12, 2018 · 0 comments

Comments

@Samigos
Copy link

Samigos commented May 12, 2018

I'm using this module just for fetching the width and height of stored images in my parse server.
I've noticed there are times that the width and height are fetched in reverse, meaning the width is the actual height and the height is the actual width!

Here's the function I'm calling inside an afterSave trigger:

var storeImageDimensions = function(postObject) {
	var imageFile = postObject.get("imageLowQuality");
	
	Parse.Cloud.httpRequest({
		url: imageFile.url(),
		success: function(response) {
			// The file contents are in response.buffer.
			var Image = require("parse-image");
			var image = new Image();
			
			// ----------------------------------
			
			image.setData(response.buffer, {
				success: function() {
					var imageDimensions = {};
					
					imageDimensions.width = image.width();
					imageDimensions.height = image.height();
					
					// ----------------------------------
					
					postObject.set("imageDimensions", imageDimensions);
					postObject.save(null, {useMasterKey: true});
				},
				error: function(error) {
				  // The image data was invalid.
				}
			})
		},
		error: function(error) {
		  // The networking request failed.
		}
	});
}

Any idea why's that happening?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant