Processing whole directories of images

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
Tom2112
Posts: 2
Joined: 2017-12-07T07:45:23-07:00
Authentication code: 1152

Processing whole directories of images

Post by Tom2112 » 2017-12-07T08:11:28-07:00

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?

olidem
Posts: 7
Joined: 2017-12-07T05:01:39-07:00
Authentication code: 1152

Re: Processing whole directories of images

Post by olidem » 2017-12-07T09:00:09-07:00

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.

User avatar
GeeMack
Posts: 507
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Processing whole directories of images

Post by GeeMack » 2017-12-07T10:06:16-07:00

Tom2112 wrote:
2017-12-07T08:11:28-07:00
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)
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.

Tom2112
Posts: 2
Joined: 2017-12-07T07:45:23-07:00
Authentication code: 1152

Re: Processing whole directories of images

Post by Tom2112 » 2017-12-07T10:43:59-07:00

Thank you, GeeMack!!! That's exactly what I was looking for/missing!

Post Reply