Page 1 of 1

How should approach this with IM batch tool?

Posted: 2011-08-01T15:22:26-07:00
by projapati
I have a folder with 1-60 images of 2MB avg size each. So total 120MB.
Now I need to process this folder files in batch to generate 1024px, 640px, 24px and 75px square size images for each of the photos.
The converted photos (after resize) should go to different folders.

Q1 - Do I have to give 4 convert commands (one for each) or I can do this in oneshot?
Q2 - What is the best way to do this so that it runs faster?

This is what I am trying, but I get error on the output folder:

>convert.exe *.jpg -sampling-factor 4:4:4 -quality 95 -resize 640x640 -unsharp 0x1 -path "c:\Temp\destination\"
Magick: unrecognized option `-path' @ error/convert.c/ConvertImageCommand/2211.

I am giving the command from the folder where I have the images.
Q3 - Why is this failing on the -path variable?

Re: How should approach this with IM batch tool?

Posted: 2011-08-01T16:56:05-07:00
by fmw42
-path is for mogrify and not convert. with convert you just specify the output path and filename. convert must have a filename specified -- it does not work on the input filename as the output filename. perhaps you need 4 mogrify commands. see http://www.imagemagick.org/Usage/basics/#mogrify and http://www.imagemagick.org/Usage/basics/#cmdline

Re: How should approach this with IM batch tool?

Posted: 2011-08-01T17:16:19-07:00
by projapati
I changed the command a bit:
>convert.exe -sampling-factor 4:4:4 -quality 95 -resize 640x640 -unsharp 0x1 *.jpg C:\Temp\output\

This seems converting all files in the current folder writing to the output folder.
But the converted files in output\ have weird names like -0, -1, -2 etc

What other option do I need so that convert keeps the filename?

There should be some way to batch convert a set of files in a folder and write output to some other folder, not?

Re: How should approach this with IM batch tool?

Posted: 2011-08-01T18:01:29-07:00
by fmw42
convert.exe -sampling-factor 4:4:4 -quality 95 -resize 640x640 -unsharp 0x1 *.jpg C:\Temp\output\
You cannot do C:\Temp\output\ for output in convert as I tried to explain before. You have to give it the exact filename you want to use for each input. It does not get the input filename and use it for the output (as mogrify does). I believe you will need to either write a script to process you files or use multiple mogrify commands. Mogrify can process every file in a folder and put the output in another folder using wild cards to get the input names and use the same filenames in the new folder for output. But you can only write one output per input with mogrify. So if you need multiple output sizes then you need one mogrify command for each size.

Convert can generate all output sizes in one command. But it cannot process many input files at once due to memory limitation that mogrify does not have. But it also cannot use wildcards for the output in the sense you are trying to do it. You can make multiple outputs by using -write ... within your convert commands by processing in sequence or with parenthesis to separate each resize. In current version of IM you can use a -set to specify the filename of the input for use in the output.

see
http://www.imagemagick.org/Usage/basics/#parenthesis
http://www.imagemagick.org/Usage/files/#write
http://www.imagemagick.org/Usage/files/#save_escapes

I believe the simplest and cleanest thing for you would be the use of mogrify, especially if you have many images to process as convert has memory limitation that mogrify does not.

Again see
http://www.imagemagick.org/Usage/basics/#mogrify

something like the following:

mkdir newdirectory
cd to current directory with images
mogrify -path fullpathto/newdirectory -format jpg -sampling-factor 4:4:4 -quality 95 -resize 640x640 -unsharp 0x1 *.jpg