excellenteasy / grunt-image-resize

Unmaintained. If you'd like to take this over please let us know. Resizing images made easy - thanks to imagemagick.
MIT License
57 stars 46 forks source link

Add option to define aspect ratio instead of exact widths #21

Open TxHawks opened 9 years ago

TxHawks commented 9 years ago

It would be good to have an option to specify an aspect ratio instead of an explicit width and height, and have those be determined by the individual file's dimension.

For instance, If I have a folder with the following image files and dimensions, and I want all of them to end up being resized to a 16:9 format: a.jpg - 1200px * 800px b.png - 1920px * 1200px c.jpg - 200px * 200px d.jpg - 800px * 400px

I could have them all set to a certain width and height, but that may mean some of them will be inflated, which isn't desirable.

A better option would be add an aspect-ratio option, say 16:9 in this case, and have resizing be based on the image dimensions and specified ratio. With the above files as example, we would end up with the following files in the dist folder: a.jpg - 1200px675px b.png - 1920px * 1080px c.jpg - 200px * 112px d.jpg - 711px \ 400px

AndreBaumeier commented 8 years ago

+1 on this extending to only fill either height or width and resize keeping ratio would be a great option as well