Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CLI ImageMagick resize (downscale only)

I would like to resize (only if neccessary) an image to maximum resolution of 800x600. So let's say we have image of resolution 2000x1600 and it will resize to 750x600, but if I have an image of resolution 400x300 it will leave as it is. In other words I need ImageMagick to resize images without upscaling. How can I do this?

convert -resize 800x600 input output does downscale but also upscale.

like image 635
Gargauth Avatar asked Aug 17 '10 16:08

Gargauth


2 Answers

Solved it: convert -resize 800x600\> input output will resize only if width is larger than 800px OR height is larger than 600px.

like image 78
Gargauth Avatar answered Oct 23 '22 04:10

Gargauth


if you want to resize the current file try mogrify -resize 800x600\> *.jpg
this will resize all jpg images with more than 800 pixels width or 600 height.

like image 35
Sagiv Ofek Avatar answered Oct 23 '22 04:10

Sagiv Ofek