moxie icon indicating copy to clipboard operation
moxie copied to clipboard

Can't get the size of a gif image?

Open burzum opened this issue 8 years ago • 3 comments

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());
});

burzum avatar Jul 27 '17 13:07 burzum

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.

jayarjo avatar Jul 27 '17 16:07 jayarjo

@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?

burzum avatar Jul 27 '17 16:07 burzum

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

jayarjo avatar Jul 28 '17 03:07 jayarjo