Search code examples
node.jsimagemagickgraphicsmagick

Node gm - resize image and preserve aspect ratio?


Does Node gm have built-in support for resizing an image while preserving aspect ratio (ie., generating a thumbnail)? Or should I get the image size, calculate the proper ratio, and then call resize?

This question is inspired by PIL's similar functionality.


Solution

  • Jonathan's comment is the solution:

    gm().resize(maxSize)
    

    This resizes the image to width maxSize. See the relevant documentation.