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?
Asked
Active
Viewed 5.8k times
2 Answers
139
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.
moropus
- 3,464
- 1
- 20
- 30
-
9imagemagick comes with `mogrify` which will alter original image. I found it easiser to copy the images into a new folder then run `mogrify -resize 512x *.jpg` – Lex Feb 05 '15 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: http://stackoverflow.com/questions/4906579/how-to-use-bash-to-create-a-folder-if-it-doesnt-already-exist – Paul Rougieux Feb 09 '15 at 15:31
90
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
Christof Aenderl
- 3,763
- 3
- 31
- 44
-
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. – MTranchant Jan 29 '15 at 09:37
-
3@MTranchant & chrise : AFAICS, `-geometry 100x200` behaves as `min(100x, x200)` (ImageMagick 6.9.2.7, Fedora 23). – Skippy le Grand Gourou Apr 27 '16 at 13:05