Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get the size of a gif image? #172

Open
burzum opened this issue Jul 27, 2017 · 3 comments
Open

Can't get the size of a gif image? #172

burzum opened this issue Jul 27, 2017 · 3 comments

Comments

@burzum
Copy link

burzum commented Jul 27, 2017

Moxie doens't support reading of gif image sizes? The following code, used with plupload, returns always false for gif but works fine for png and jpg.

Please not that the gif I'm trying to use is an animated gif.

plupload.addFileFilter('min_img_resolution', function(maxRes, file, cb) {
	var self = this;
	var img = new window.moxie.image.Image();

	function finalize(result) {
		// cleanup
		img.destroy();
		img = null;

		// if rule has been violated in one way or another, trigger an error
		if (!result) {
			self.trigger('Error', {
				code: plupload.IMAGE_DIMENSIONS_ERROR,
				message: 'Image should be at least ' + maxRes[0] + ' pixels wide.',
				file: file
			});
		}
		cb(result);
	}

	img.onload = function() {
		finalize(img.width >= maxRes[0] && img.height >= maxRes[1]);
	};

	img.onerror = function() {
		finalize(false);
	};

	img.load(file.getSource());
});
@jayarjo
Copy link
Contributor

jayarjo commented Jul 27, 2017

Right, gif is not considered a proper image at the moment. Mostly because we weren't sure how to handle animated gifs. Suggestions are welcome.

@burzum
Copy link
Author

burzum commented Jul 27, 2017

@jayarjo thanks for the quick response. I've seen the ticket with the discussion about the animation. But animation is another topic, the size doesn't change. So a first step would be to get the right size for gifs.

As for animations... well. There must be a way to do it. I've seen another site (competitor of my company) doing it: You upload the file. They show an animated (!) thumbnail and in an overlay the upload progress bar. So I know it's somehow doable. I just haven't had more time yet to figure out how they do it / what lib they use.

Is there any other way or library I could use to get what we need?

@jayarjo
Copy link
Contributor

jayarjo commented Jul 28, 2017

@burzum yes, we could extract the size and even create a thumbnail. However resizing would whole other matter.

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

No branches or pull requests

2 participants