Page 1 of 1

single command that handles different things

Posted: 2013-09-14T06:33:32-07:00
by Frank1000
Hi, using latest stand alone win7 with command-line and wanted to make one single command that handles different things in one go. My breakdown is:

* read Background.png
* read Foreground_Name.png
* crop Foreground_Name.png while reading, with -crop 709x310+229+385
* compose cropped Foreground_Name with offset -gravity NorthWest+229+385
* save result as Result_Name.jpg with quality-factor 80%
* delete Foreground_Name.png

the Names part of the Foreround_Name.png i can store as names.txt like:
name-one
name-two
name-abc-three
...

Here is what i got so far, but syntax not pefect yet:

convert ^
Background.png ^
\( -crop 709x310+229+385 ^
'Foreground_%[filename:names].png' \) ^
\( -compose ^
-gravity NorthWest+229+385 ^
'Result_%[filename:names].jpg' -quality 80% \) ^
| rm 'Foreground_%[filename:names].png'

* for deleting i had checked viewtopic.php?f=1&t=15877

Please share how setting up correctly.

Regards,
Frank

Re: single command that handles different things

Posted: 2013-09-14T07:21:18-07:00
by snibgo
"rm" is a Unix command, not a Windows command. In Windows, parentheses don't normally need escaping. If they do need it, use "^" not "\". See http://www.imagemagick.org/Usage/windows/

If you want to apply the same command to name-one, then name-two, then name-abc-three, etc, I would put those names in a file (as you have), and read through that file with a "for" loop, eg:

Code: Select all

for /F %%A in (names.txt) do convert ... Foreground_%%A.png ...
If you want to delete Foreground_%%A.png after the command, use ephemeral:Foreground_%%A.png