Page 1 of 1

Batch converting in imagemagic

Posted: 2019-10-03T21:27:43-07:00
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.

Re: Batch converting in imagemagic

Posted: 2019-10-03T21:54:45-07:00
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