imageterminalimagemagickmogrify

Imagemagick – Converting portrait and landscape images to the largest size


I have large portrait and landscape images. For example: 5000x3000 pixels and 2000x8000 pixels.

I want to scale them down to 502 pixels, keeping the aspect ratio, despite their orientation, so the largest size of all images will always be 502 pixels.

I found these lines on Stack Overflow, that were supposed to do the job

find . -type f -exec convert {} -resize "502>" {} \; 

or

find ./*.jpeg -exec convert {} -resize "502>" {} \; 

I type them and the console freezes. Nothing happens.

I know that there is a command to do that with convert or mogrify, cause I did it in the past, but I cannot remember the command line now.

I want to discover a way to do it thru terminal.

I am on macOS Sonoma.


Solution

  • If the files are all in one directory, you don't need find you can simply use mogrify, e.g.

    magick mogrify -resize '502>' *.jpg