I would like to resize image upon upload with Meteor CollectionFS. But I would like to resize based on image dimensions. For example, I want to resize image that is 1000x500 into 1024x512, but 60x100 into 64x128 - for that I need to know source dimensions.
I am basing my code on one provided by CollectionFS documentation:
var createThumb = function(fileObj, readStream, writeStream) {
// Transform the image into a 10x10px thumbnail
gm(readStream, fileObj.name()).resize('10', '10').stream().pipe(writeStream);
};
how do I get source dimensions here, to make my resize target dynamic? Maybe there are some graphicsmagick function?