Batch converting in imagemagic

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
markosjal
Posts: 7
Joined: 2018-04-20T13:15:16-07:00
Authentication code: 1152

Batch converting in imagemagic

Post by markosjal »

I am trying to convert files in imagemagic 6.8.9 on linux . I am restoring an old video and have each frame written as a png file . Some of these files I have to batch convert to give them an offset -1-4 with the following command to "move" the image in the frame (compensate for a shift in the video).

Code: Select all

convert test.png -repage -1-4 -background black -flatten newtest.png
That command does what I need for a single file however I need to preserve the original file names, and do this for hundreds of files.

When I try to use wildcards only the last file is converted using the wildcard used in the command.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch converting in imagemagic

Post by fmw42 »

Create a new folder to hold the output. CD to the directory with your input image. Then use mogrify to process all the images in the folder with the following

Code: Select all

mogrify -format png -path path_to/newfolder -repage -1-4 -background black -flatten *.png
It will loop over each image in the old directory and use the same name for the images it puts into the new directory.

See https://imagemagick.org/Usage/basics/#mogrify
Post Reply