Page 1 of 1

Command Line help controlling output name and folder

Posted: 2012-05-04T11:38:14-07:00
by jonsgro
Hi,

I just started using ImageMagick-6.7.6-Q16 for creating thumbnails for large numbers of images.

I've been struggling though trying to get the "convert" and/or "mogrify" commands to output to folders and filenames that i want.
I have sort of gotten the results that i want by using "convert" but i'm having issues w/ that due to it crashing after running out of memory, i realize "mogrify" would be much preferable to use since it opens up each image one at a time - but mogrify doesn't like to use the "-set" flag which i've found necessary to get the output filename that i desire. I also need the thumbnails in a subfolder of the image's folder.

I'm calling convert like this currently (where my command is run in the subfolder where i want the output images to go)...
C:\ImageFolder\thumbs\convert "C:\ImageFolder\*.tga" -format png -thumbnail 64x64 -set filename:orig %f %[filename:orig].png
or
C:\ImageFolder\thumbs\convert @"C:\ImageFolder\createThumbs.txt" -format png -thumbnail 64x64 -set filename:orig %f %[filename:orig].png

So my questions:
1) is there a way for me to use mogrify and get the output filename to be the input file name w/ original ext plus the new ext. such as "blah.tga" would output to "blah.tga.png"
2) when calling convert or mogrify where i use a txt file to specify the files to convert, is there a way to get each individual output image to go to a subfolder of it's source image. such as i have images c:\FolderA\testA.tga and c:\FolderB\testB.tga listed in the txt file. i would want the output to be c:\FolderA\thumbs\testA.tga.png and c:\FolderB\thumbs\testB.tga.png

I'm currently limiting how many files i pass through to "convert" as a workaround for the memory issue, but that's a hack.
Some people may suggest other workarounds by using a batch file, but i'm limited w/ what i can do in that respect due to the fact that i'm calling these commands from another program and am limited in how i can call the command line from there.

Thanks for any help,

Re: Command Line help controlling output name and folder

Posted: 2012-05-04T13:43:35-07:00
by fmw42
I am not sure mogrify is that sophisticated. It is much more restrictive than convert.

The best way is to write a loop over each image in your directory and then output to your subdirectory.

Alternately, see
http://www.imagemagick.org/Usage/basics/#mogrify_not

Re: Command Line help controlling output name and folder

Posted: 2012-05-04T15:49:55-07:00
by jonsgro
at this point i might as well just write out a long batch file (.bat) that has each file listed, and change the output subdir per image too...
cd c:\FolderA\thumbs
convert "C:\FolderA\testA.tga -format png -thumbnail 64x64 -set filename:orig %f %[filename:orig].png
cd c:\FolderB\thumbs
convert "C:\FolderB\testB.tga -format png -thumbnail 64x64 -set filename:orig %f %[filename:orig].png
etc...

i was hoping to avoid the overhead of calling "convert" over and over again, it must increase the time compared to just calling "mogrify".

this software seems so robust, i'm just surprised it doesn't have better control over output naming and folders.

anyone else have thoughts?

Re: Command Line help controlling output name and folder

Posted: 2012-05-04T19:08:42-07:00
by fmw42
Wait for Anthony to reply. He knows mogrify better than I.

Re: Command Line help controlling output name and folder

Posted: 2012-05-05T10:09:44-07:00
by whugemann
I guess that you are working under Windows (?), soe you should use a FOR loop for your bulk conversion, see http://www.imagemagick.org/Usage/windows/#for_loops

Re: Command Line help controlling output name and folder

Posted: 2012-05-08T23:38:32-07:00
by anthony
Note that mogrify will read and process each image ONE at a time

Convert however reads in ALL images before processing.

IMv7 will have more options, but I am no where near, looking to replace "mogrify" with the new "magick" command as yet.
But it will happen! Probably after I have implemented 'functions' :-) Yes I have ideas for that sort of thing!