javascript - Conditional Resizing using cfs:graphicsmagick -


currently, i'm storing images (profile images) on amazon s3, working perfectly. i'm resizing images 300px wide using cfs:graphicsmagick, want doing if they're wider 300px. if someone's uploading smaller, don't want scaling up, make awful.

my current code (not conditional) 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 can see, i'm handling using transformwrite in fs.store.s3 object. read documentation node.js library that's in use (gm), , see there's .size() function, wasn't able working. how can images scaled conditionally?

thanks in advance.

append

  • '>' maximum width/height
  • '^' minimum width/height

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

excerpt graphicmagick doc:

by default, width , height maximum values. is, image expanded or contracted fit width , height value while maintaining aspect ratio of image.

append ^ geometry image resized while maintaining aspect ratio of image, resulting width or height treated minimum values rather maximum values.

append exclamation point geometry force image size size specify. example, if specify 640x480! image width set 640 pixels , height 480.

use > change dimensions of image if width or height exceeds geometry specification. < resizes image if both of dimensions less geometry specification. example, if specify '640x480>' , image size 256x256, image size not change. however, if image 512x512 or 1024x1024, resized 480x480. enclose geometry specification in quotation marks prevent < or > being interpreted shell file redirection.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -