Batch conversion
Batch conversion
Dear All,
I would like to convert files which are in one directory to another (resizing, format conversion and put a text into the picture). I managed to write for every command a command line which worked for one file but not for all. I am using ImageMagick 7.0 and Windows 10.
The conversion for one file is
C:\Programme\ImageMagick-7.0.6-Q16\magick C:\temp\Bildquelle\test1.jpg -compress LZW C:\temp\bildablage\test1.tif
C:\Programme\ImageMagick-7.0.6-Q16\magick C:\temp\Bildbearbeitung\test1.tif -fill black -pointsize 120 -font arrial -annotate +100+200 %f C:\temp\Bildumbenennung\test1_bearb.tif
C:\Programme\ImageMagick-7.0.6-Q16\magick C:\temp\Bildbearbeitung\*test1.tif -resize 16% C:\temp\bildgroesse\test1_og.tif
Now I want to convert all (e.g. 20) files and replaced “test1.jpg/test1.tif” with “*.jpg/*.tif”; “*”as a wild card. No reaction.
I have read http://www.imagemagick.org/Usage/windows/#file_handling but I have not understood it. Shall I use “%%a” instead of “*” or what else is necessary to do?
Perhaps someone can help me
Thanks in advance
Uli
I would like to convert files which are in one directory to another (resizing, format conversion and put a text into the picture). I managed to write for every command a command line which worked for one file but not for all. I am using ImageMagick 7.0 and Windows 10.
The conversion for one file is
C:\Programme\ImageMagick-7.0.6-Q16\magick C:\temp\Bildquelle\test1.jpg -compress LZW C:\temp\bildablage\test1.tif
C:\Programme\ImageMagick-7.0.6-Q16\magick C:\temp\Bildbearbeitung\test1.tif -fill black -pointsize 120 -font arrial -annotate +100+200 %f C:\temp\Bildumbenennung\test1_bearb.tif
C:\Programme\ImageMagick-7.0.6-Q16\magick C:\temp\Bildbearbeitung\*test1.tif -resize 16% C:\temp\bildgroesse\test1_og.tif
Now I want to convert all (e.g. 20) files and replaced “test1.jpg/test1.tif” with “*.jpg/*.tif”; “*”as a wild card. No reaction.
I have read http://www.imagemagick.org/Usage/windows/#file_handling but I have not understood it. Shall I use “%%a” instead of “*” or what else is necessary to do?
Perhaps someone can help me
Thanks in advance
Uli
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Batch conversion
If you only need the final result test1_og.tif, then you can process a full directory of images using mogrify. See http://www.imagemagick.org/Usage/basics/#mogrify
#create a new directory to hold the output images (path2/outputfolder)
#cd to directory holding input images
#create a new directory to hold the output images (path2/outputfolder)
#cd to directory holding input images
Code: Select all
magick mogrify -format tif -path path2/outputfolder -fill black -pointsize 120 -font arial -annotate +100+200 "%f" -resize 16% -compress LZW *.jpg
Re: Batch conversion
Dear
thank you for your answer.
I have read the site you recommended before, but later I was told that with IM v7 only "magick" can be used.
Therefore I wrote the command line:
C:\Programme\ImageMagick-7.0.6-Q16\magick C:\temp\Bildquelle\test1.jpg -compress LZW C:\temp\bildablage\test1.tif and it works for o n e file.
I have tried your command line only for the format conversation and the compression (the three different steps (format conversion; resize; put name in picture) should not be mixed and they have all different input and output directories)):
mogrify -format tif -path C:\temp\bildablage -compress LZW *.jpg
and no reaction (for sure), because I had not defined the path which holds the input files. How do I define the directory holding the input files?
But is there no other way with IM v7.0? My command line works with one file but what is to do to use it for all files in one directory?
Thanks
Uli
thank you for your answer.
I have read the site you recommended before, but later I was told that with IM v7 only "magick" can be used.
Therefore I wrote the command line:
C:\Programme\ImageMagick-7.0.6-Q16\magick C:\temp\Bildquelle\test1.jpg -compress LZW C:\temp\bildablage\test1.tif and it works for o n e file.
I have tried your command line only for the format conversation and the compression (the three different steps (format conversion; resize; put name in picture) should not be mixed and they have all different input and output directories)):
mogrify -format tif -path C:\temp\bildablage -compress LZW *.jpg
and no reaction (for sure), because I had not defined the path which holds the input files. How do I define the directory holding the input files?
But is there no other way with IM v7.0? My command line works with one file but what is to do to use it for all files in one directory?
Thanks
Uli
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Batch conversion
You have to create a new directory to put your output image via your OS. ImageMagick does not create it. Once it is created, then in mogrify supply the path to the already created output directory. Your command looks fine, except you have to create your output directory before running mogrify. There is no reason you cannot do all your commands in on command line. There is no issue with mixing them.
However if you need to save each step to a different directory rather than just the final result, then you cannot use mogrify. You would have to write a loop in your OS that would access each image, do each step and +write path/image.suffix to the directory you want it to be saved.
See
http://www.imagemagick.org/Usage/files/#write
http://www.imagemagick.org/script/comma ... .php#write
However if you need to save each step to a different directory rather than just the final result, then you cannot use mogrify. You would have to write a loop in your OS that would access each image, do each step and +write path/image.suffix to the directory you want it to be saved.
See
http://www.imagemagick.org/Usage/files/#write
http://www.imagemagick.org/script/comma ... .php#write
Re: Batch conversion
Dear fmw 42,
thank you for your answer.
Is there no possibility to do that kind of batch conversion with IM 7.0 for all files instead of only one?
I read on the web site of ImageMagick 7.0 under Command Changes: "To reduce the footprint of the command-line utilities, these utilities (i.e. mogrify) are symbolic links to the magick utility." So I think it must be possible.
Thanks
Uli
thank you for your answer.
Is there no possibility to do that kind of batch conversion with IM 7.0 for all files instead of only one?
I read on the web site of ImageMagick 7.0 under Command Changes: "To reduce the footprint of the command-line utilities, these utilities (i.e. mogrify) are symbolic links to the magick utility." So I think it must be possible.
Thanks
Uli
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Batch conversion
In IM 7, you must add magick before all other commands such as mogrify, except for convert. So If you want to do mogrify, it would be
If you want to do something else, then please clarify what it is you want to do. If you need to write images from each function to a separate directory for every input image, then you will need to create loop over each image and process that image with magick (formerly convert in IM 6) and use +write to save results of each step to different directories. Mogrify can not write multiple output images for a given input image.
Code: Select all
magick mogrify -format tif -path path2/outputfolder -fill black -pointsize 120 -font arial -annotate +100+200 "%f" -resize 16% -compress LZW *.jpg
Re: Batch conversion
Dear fmw42,
thank you for your answer, I think I have not specified my question enough.
Let us start again.
ooooo
I have three different command lines written with IM 7. They can not be put together, because they have nothing to do with each other. For instance I don’t want to resize the photo which has its file name on it.
Therefore all command-lines have different input and different output files. Neither the directories of the input nor the directories of the output files can be changed; they are fixed.
The command-lines are
1)
C:\Programme\ImageMagick-7.0.6-Q16\magick C:\temp\bildquelle\test1.jpg -compress LZW C:\temp\bildablage\test1.tif
Input file C:\temp\bildquelle
Output file C:\temp\bildablage
2)
C:\Programme\ImageMagick-7.0.6-Q16\magick C:\temp\bildbearbeitung\test1.tif -fill black -pointsize 120 -font arrial -annotate +100+200 %f C:\temp\bildumbenennung\test1_bearb.tif
Input file C:\temp\bildbearbeitung
Output file C:\temp\bildumbenennung
3)
C:\Programme\ImageMagick-7.0.6-Q16\magick C:\temp\bildfreistellung\test1.tif -resize 16% C:\temp\bildgroesse\test1_og.tif
Input file C:\temp\bildfreistellung
Output file C:\temp\bildgroesse
oooooo
I am using windows 10 and prompt for the execution of the command lines. All command-lines work well for one file in the directory.
I want to manipulate the command-lines in such a way that I can do the operation for all files in one directory. So my problem is three times the same.
Starting with IM I read a lot of using “mogrify” “convert” and other commands. My problem was that I had no idea how to define the input file.
So I was happy with IM 7 because the construction of the command-line was different.
Now you always speak about mogrify but I still have the problem that I do not know how to define the input path. Reading your yesterdays answer (You have to create a new directory to put your output image via your OS. ImageMagick does not create it. Once it is created, then in mogrify supply the path to the already created output directory. Your command looks fine, except you have to create your output directory before running mogrify) I have tried it, but with no result. Can you re-write for instance the following command for using mogrify with IM 7 or can yougive me an example?
C:\Programme\ImageMagick-7.0.6-Q16\magick C:\temp\bildquelle\test1.jpg -compress LZW C:\temp\bildablage\test1.tif
oooooo
When I install IM 7 the installation of mogrify was optional (with the legacy box) so it is not necessary. Or am I wrong?
I need to replace the name of the file with a wild card (for example *.jpg instead of test1.jpg) that allows me to use the command line for all files (https://www.imagemagick.org/discourse-s ... hp?t=15737; https://www.imagemagick.org/discourse-s ... rd#p145532 ).
Thanks
UliW
thank you for your answer, I think I have not specified my question enough.
Let us start again.
ooooo
I have three different command lines written with IM 7. They can not be put together, because they have nothing to do with each other. For instance I don’t want to resize the photo which has its file name on it.
Therefore all command-lines have different input and different output files. Neither the directories of the input nor the directories of the output files can be changed; they are fixed.
The command-lines are
1)
C:\Programme\ImageMagick-7.0.6-Q16\magick C:\temp\bildquelle\test1.jpg -compress LZW C:\temp\bildablage\test1.tif
Input file C:\temp\bildquelle
Output file C:\temp\bildablage
2)
C:\Programme\ImageMagick-7.0.6-Q16\magick C:\temp\bildbearbeitung\test1.tif -fill black -pointsize 120 -font arrial -annotate +100+200 %f C:\temp\bildumbenennung\test1_bearb.tif
Input file C:\temp\bildbearbeitung
Output file C:\temp\bildumbenennung
3)
C:\Programme\ImageMagick-7.0.6-Q16\magick C:\temp\bildfreistellung\test1.tif -resize 16% C:\temp\bildgroesse\test1_og.tif
Input file C:\temp\bildfreistellung
Output file C:\temp\bildgroesse
oooooo
I am using windows 10 and prompt for the execution of the command lines. All command-lines work well for one file in the directory.
I want to manipulate the command-lines in such a way that I can do the operation for all files in one directory. So my problem is three times the same.
Starting with IM I read a lot of using “mogrify” “convert” and other commands. My problem was that I had no idea how to define the input file.
So I was happy with IM 7 because the construction of the command-line was different.
Now you always speak about mogrify but I still have the problem that I do not know how to define the input path. Reading your yesterdays answer (You have to create a new directory to put your output image via your OS. ImageMagick does not create it. Once it is created, then in mogrify supply the path to the already created output directory. Your command looks fine, except you have to create your output directory before running mogrify) I have tried it, but with no result. Can you re-write for instance the following command for using mogrify with IM 7 or can yougive me an example?
C:\Programme\ImageMagick-7.0.6-Q16\magick C:\temp\bildquelle\test1.jpg -compress LZW C:\temp\bildablage\test1.tif
oooooo
When I install IM 7 the installation of mogrify was optional (with the legacy box) so it is not necessary. Or am I wrong?
I need to replace the name of the file with a wild card (for example *.jpg instead of test1.jpg) that allows me to use the command line for all files (https://www.imagemagick.org/discourse-s ... hp?t=15737; https://www.imagemagick.org/discourse-s ... rd#p145532 ).
Thanks
UliW
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Batch conversion
Many "convert" commands can be converted to "mogrify" or "magick mogrify". But if you have "convert" commands that do what you want, it may be easier to put them inside "for" loops.
snibgo's IM pages: im.snibgo.com
Re: Batch conversion
Thank you snibgo,
but what must be written instead of „ C:\temp\bildquelle\test1” to do the processing for all files in the input directory?
Is it “*”, “%”, “$” or anything else?
Thanks
UliW
but what must be written instead of „ C:\temp\bildquelle\test1” to do the processing for all files in the input directory?
Is it “*”, “%”, “$” or anything else?
Thanks
UliW
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Batch conversion
You had this:
To do that with mogrify:
Code: Select all
C:\Programme\ImageMagick-7.0.6-Q16\magick C:\temp\bildquelle\test1.jpg -compress LZW C:\temp\bildablage\test1.tif
Code: Select all
C:
cd \temp\bildquelle
C:\Programme\ImageMagick-7.0.6-Q16\magick mogrify -path C:\temp\bildablage -compress LZW *.jpg
snibgo's IM pages: im.snibgo.com
Re: Batch conversion
Dear snibgo,
thank you for your answer.
I think my main mistake was to use the windows prompt instead of the windows shell. Now it works pretty well (I must tell the program not to import the old jpg-files into the new output file, but I hope to find out how to do this after digging through a hundreds of answers concerning batch conversions).
But to be sure: Is there no other way to carry out that kind of processing other than using mogrify ? What puzzles me is the fact that the installation of mogrify is optional on IM 7.0.
Thanks
Uli
thank you for your answer.
I think my main mistake was to use the windows prompt instead of the windows shell. Now it works pretty well (I must tell the program not to import the old jpg-files into the new output file, but I hope to find out how to do this after digging through a hundreds of answers concerning batch conversions).
But to be sure: Is there no other way to carry out that kind of processing other than using mogrify ? What puzzles me is the fact that the installation of mogrify is optional on IM 7.0.
Thanks
Uli
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Batch conversion
The example I showed uses "magick mogrify". That is, it uses the "magick.exe" program.
An alternative is the "mogrify.exe" program.
Other alternative are to use "convert.exe" or "magick convert" or simply "magick", inside a for loop.
An alternative is the "mogrify.exe" program.
Other alternative are to use "convert.exe" or "magick convert" or simply "magick", inside a for loop.
snibgo's IM pages: im.snibgo.com
Re: Batch conversion
Dear snibgo,
thank you for your answer.
UliW
thank you for your answer.
UliW