Search code examples
shellcommand-lineimagemagickimagemagick-convert

Resizing images with imagemagick when they are larger than 10mb


I'm trying to resize images larger than 10 mb.

This is my imagemagick commando: convert -strip -interlace Plane -resize 70% -quality 80% file.jpg file.jpg

Can someone explain to me how i loop over the images in folder that are larger than 10mb?


Solution

  • Use find:

    find /your/path/here -name '*.jpg' -size +10M -exec convert -strip -interlace Plane -resize 70% -quality 80% {} {} \;
    

    This finds all files larger than 10 Megabytes and with names ending in .jpg and executes the command on them. {} is a placeholder for the name of the current file.