Currently, I'm storing images (profile images) on Amazon S3, which is working perfectly. I'm resizing images to be 300px wide using cfs:graphicsmagick, but I only want to be doing this if they're wider than 300px. If someone's uploading something smaller, I don't want to be scaling it up, which would make it look awful.
My current code (not conditional) is as follows:
var profileStore = new FS.Store.S3("profileImages", {
accessKeyId: "--KEY--",
secretAccessKey: "--KEY--",
bucket: "meteor-intrepid",
folder: "profiles",
transformWrite: function(fileObj, readStream, writeStream) {
gm(readStream, fileObj.name()).resize('300').stream().pipe(writeStream);
}
});
As you can see, I'm handling this using a transformWrite
in my FS.Store.S3 object. I read the documentation for the Node.js library that's in use (gm), and I see that there's a .size() function, but I wasn't able to get it working. How can images be scaled conditionally?
Thanks in advance.