2

I have a bunch of images in a folder with different dimensions and ratio.

I want to shrink all of them while keeping a minimum height and width, while keeping the same ratio.

Something like:
convert -resize -minwidth 300 -minheight 200 -keep-ratio src *.jpg

Then all shrinked images would have at least 300 width and 200 height, and they will retain the original ratio.

Is this even possible without some heavy scripting?

Things I've tried:

➜  swazidowners mogrify -resize 300x200^ "*.jpg"
zsh: no matches found: 300x200^
➜  swazidowners mogrify -resize 300x200^ bbq.jpg
zsh: no matches found: 300x200^
➜  swazidowners mogrify -resize 300x200 bbq.jpg # just to show that it works without ^ character
➜  swazidowners 

System info:
OS: Ubuntu 16.04x64

$ mogrify -version  
Version: ImageMagick 6.8.9-9 Q16 x86_64 2016-11-29 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib
5
mogrify -resize '300x200^' *.jpg

make sure you run this on a copy of your images as it replaces them.

  • I'm getting zsh: no matches found: 300x200^ – Adam Goldman Jan 13 '17 at 9:14
  • normally you would get this message if there are no files found that match *.jpg, but I assume you have right? – Kees Beets Jan 13 '17 at 12:27
  • yup, I have and I tested multiple time :( Does that work for u? – Adam Goldman Jan 13 '17 at 13:38
  • yes, using ubuntu 16.04 and imagemagick (8:6.8.9.9-7ubuntu5.3) – Kees Beets Jan 13 '17 at 15:13
  • could you try to use quotes: mogrify -resize 300x200^ "*.jpg" – Kees Beets Jan 13 '17 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.