single command that handles different things

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Frank1000
Posts: 14
Joined: 2013-09-14T05:33:01-07:00
Authentication code: 6789

single command that handles different things

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: single command that handles different things

Post 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
snibgo's IM pages: im.snibgo.com
Post Reply