Using the imagemagick convert command, how can I resize an image to a fixed width and proportional height e.g. using the -resize or the -thumbnail option?
2 Answers
Use -resize 100x
to resize images to 100 pixels in width while maintaining the height's aspect ratio.
Read the fine ImageMagick manual for details.
-
9imagemagick comes with
mogrify
which will alter original image. I found it easiser to copy the images into a new folder then runmogrify -resize 512x *.jpg
– LexFeb 5, 2015 at 10:08 -
2mkdir will complain if the directory already exists. To avoid this, add the -p flag "no error if existing" to mkdir.
mkdir -p thumbnails
explained in this question: stackoverflow.com/questions/4906579/… Feb 9, 2015 at 15:31
Imagemagick geometry: 'width'x'height' If you leave one part empty, this means resize proportional.
Examples:
100x200 # width = 100, height = 200
300x # width = 300, height = proportional
x300 # width = proportional, height = 300
-
13
100x200
will create an image with theses dimensions. The original picture will keep its ratio W/H.100x200\!
will also create an image with theses dimensions, but image inside will be deformed to stick the new dimensions. Jan 29, 2015 at 9:37 -
3@MTranchant & chrise : AFAICS,
-geometry 100x200
behaves asmin(100x, x200)
(ImageMagick 6.9.2.7, Fedora 23). Apr 27, 2016 at 13:05