7

Images can be resized using mogrify from the ImageMagick suite:

mogrify -resize 256x256 *.jpg

But this will resize images so that the largest dimension is 256px, including images that are smaller than 256px to begin with (like 100x100px avatars).

How can I exclude the smaller images from being affected? i.e. I want the largest dimension to be no more than 256px

(Preferably I will be able to do this with ImageMagick suite, or at least without installing anything additional).

Zanna
  • 72,312
Craig
  • 175

2 Answers2

7

Try

mogrify -resize '1280x1024>' *.jpg

Do make sure to back up though.

Zanna
  • 72,312
DemonWareXT
  • 1,161
1

mogrify -resize '256x256>' *.jpg also modifies images it doesn't resize and changes their image data. This doesn't:

identify -format '%w %h %i\n' *.jpg|awk '$1>256||$2>256{print$3}'|xargs mogrify -quality 93 -resize 256x256

Or if the paths of the files contain spaces, single quotes, double quotes, or tabs:

identify -format '%w %h %i\n' *.jpg|awk '$1>256||$2>256'|cut -d\ -f3-|xargs -d\\n mogrify -quality 93 -resize 256x256

nisetama
  • 791