Page 1 of 1

Processing whole directories of images

Posted: 2017-12-07T08:11:28-07:00
by Tom2112
I've gone through the online documentation, and read many examples, but I'm obviously missing something rather basic.

How does one process a whole folder of image files (jpgs) while keeping the filenames intact, but putting the resulting files in a new folder? (I'm working in a Windows 10 environment, not Linux or Unix)

For example:
convert *.jpg -quality 75 -resize 1920x1920^> -unsharp 10x4+1+0 C:\Resized\
doesn't work as I had hoped.

nor does:
convert *.jpg -quality 75 -resize 1920x1920^> -unsharp 10x4+1+0 C:\Resized
nor does:
convert *.jpg -quality 75 -resize 1920x1920^> -unsharp 10x4+1+0 C:\Resized\*.jpg

So what am I missing?

Re: Processing whole directories of images

Posted: 2017-12-07T09:00:09-07:00
by olidem
Uuu-ha :) You're struggling less with imagemagick than with windows batch scripting !

I'd recommend learning some powershell commands...
http://www.computerperformance.co.uk/powershell/

another hint is mogrify, which is meant for batch processing (without writing the loops yourself). But in the end I always returned to my own looping, because mogrify is limited (or more complicated) in terms of input patterns and so on.

Re: Processing whole directories of images

Posted: 2017-12-07T10:06:16-07:00
by GeeMack
Tom2112 wrote: 2017-12-07T08:11:28-07:00How does one process a whole folder of image files (jpgs) while keeping the filenames intact, but putting the resulting files in a new folder? (I'm working in a Windows 10 environment, not Linux or Unix)
As olidem mentioned, the mogrify tool is probably better suited for this job. Try a command like this...

Code: Select all

mogrify -resize 1920x1920^> -unsharp 10x4+1+0 -quality 75 -path "C:\Resized" *.jpg
That will read all the JPG images in the current directory, resize them, and sharpen them. Then it writes the finished images with their original file names into a directory you specify with "-path ...".

There are some more complicated tasks that can't be done with "mogrify", so running "convert" in a simple "for" loop is the best approach. If your actual command is as simple as your example, "mogrify" should do what you need very well.

Re: Processing whole directories of images

Posted: 2017-12-07T10:43:59-07:00
by Tom2112
Thank you, GeeMack!!! That's exactly what I was looking for/missing!