How to resize an image but keep it's orientation and aspect ratio ? (gm)

201 views Asked by At

I would like to resize an image to a maximum height of 400px, while keeping its orientation and aspect ratio.

This resizes the image, but changes its orientation (if it is portrait it changes it to landscape).

 gm(file.stream)
    .resize('400')
1

There are 1 answers

0
Yaron On

Ah, found it.

 gm(file.stream)
    .resize('400','400')
    .autoOrient()