Reduces all images in many sub directories

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
tom445
Posts: 1
Joined: 2019-02-09T05:59:56-07:00
Authentication code: 1152

Reduces all images in many sub directories

Post by tom445 » 2019-02-09T06:03:38-07:00

Hi,

Could someone help provide me the command to achieve the following in one script:

Resize images to a maximum of 1,000px in width (therefore keeping aspect ratio)
Resize images to a maximum of 1,000px in height (therefore keeping aspect ratio)
Convert from PNG to JPG
Look in all subdirectories

I basically have 3,500 images, 70% in PNG and 30% in JPG, and I want them to be a maximum of 1,000px either height or width, and they are to replace originals.

The command I've got so far is:
convert -size 1000x1000, but I don't know how to do the rest.


Thanks a lot.

snibgo
Posts: 11333
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Reduces all images in many sub directories

Post by snibgo » 2019-02-09T07:20:12-07:00

What version of IM, on what platform?

Code: Select all

magick in.png -size 1000x1000 out.jpg
This reads one png file, resizes so the maximum dimension is 1000 pixels, and writes it as a jpg. It doesn't remove the png.

For the rest, I would use a script. Mogrify will do all the files in a single directory, but you need a script to process multiple directories.
snibgo's IM pages: im.snibgo.com

Post Reply