Page 1 of 1
Batch processing help. Is this possible?
Posted: 2011-07-10T08:06:01-07:00
by RiGLEY
Hi!
New user here. I'm writing a Windows script (AutoHotkey) for my university, which saves lots of .tif images into a directory. I have heard that Imagemagick is very good at batch image processing, so here goes my question: Lets say I have a reference file somewhere, and I want to add (or subtract) it to all of the pictures in the directory. And overwrite them. Any help would be much appreciated!
Thanks,
Daniel
Re: Batch processing help. Is this possible?
Posted: 2011-07-10T11:18:32-07:00
by fmw42
RiGLEY wrote:Hi!
New user here. I'm writing a Windows script (AutoHotkey) for my university, which saves lots of .tif images into a directory. I have heard that Imagemagick is very good at batch image processing, so here goes my question: Lets say I have a reference file somewhere, and I want to add (or subtract) it to all of the pictures in the directory. And overwrite them. Any help would be much appreciated!
Thanks,
Daniel
IM has a multi-image processing functions called mogrify that processes every image (of the type specified) in a directory. Unfortunately, it does not allow a second image to be used in conjunction with all of the other images. Thus you will need to write a script. Or see
http://www.imagemagick.org/Usage/basics/#mogrify_not
for mogrify, see
http://www.imagemagick.org/Usage/basics/#mogrify
Re: Batch processing help. Is this possible?
Posted: 2011-07-10T21:46:42-07:00
by anthony
Perhaps you need to describe or example what it is you are trying to achieve. What you have written could be interpreted in many many different ways.
It sounds like you want to take any image that appears in some directory and merge them into a existing larger image. But I can't be certain.
Re: Batch processing help. Is this possible?
Posted: 2011-07-10T21:53:07-07:00
by RiGLEY
Hi!
Thanks for the replies. The reference image won't change. The ref image has the same dimensions. I want to give the script a line of code that takes the reference image and adds (for example the pixel values) it to all of the images in a directory. It can overwrite them.
__
Daniel
Re: Batch processing help. Is this possible?
Posted: 2011-07-10T22:32:50-07:00
by anthony
Then mogrify is the solution.
However mogrify does not (currently) let you directly compose one image to multiple images (how does it know what is the reference image?). the solution is either...
Compose with Draw...
http://www.imagemagick.org/Usage/basics ... fy_compose
or use convert (read all images, process them all then write them all) -- very memory hungry
http://www.imagemagick.org/Usage/basics ... fy_convert
or a shell wrapper around convert -- runing multiple commands
http://www.imagemagick.org/Usage/basics/#mogrify_not
In IMv7 (currently being worked on) I will be creating a new alternative, a imagemagick co-process, whcih a shell script can feed image processing commands to. That is a background IM command (one only) that reads/processes/writes the images, according to commands given by a controlling shell script. This will have the same advantages as all the above, but few disadvantages.
http://www.imagemagick.org/Usage/bugs/I ... ipting.txt
However it may be some months before it is available.
Re: Batch processing help. Is this possible?
Posted: 2011-07-11T04:06:17-07:00
by whugemann
The command achieving this is:
for %i in (*.jpg) DO convert %i compare_to.jpg -compose subtract -composite mod_%i
Just open a DOS box, switch to the folder where the files are located and type the above command. When transferring the code into a batch file, you have to double the percent signs:
for %%i in (*.jpg) DO convert %%i compare_to.jpg -compose subtract -composite mod_%%i
and you can hand over the actual file to compare to:
for %%i in (*.jpg) DO convert %%i %1 -compose subtract -composite mod_%%i
DEL mod_%1
For details on batch processing with IM under Windows see the link below.
Re: Batch processing help. Is this possible?
Posted: 2011-07-11T09:29:02-07:00
by RiGLEY
I'm extremely grateful Wolfgang! Actually the other day I was browsing your page looking for some solution.
Thanks guys!