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?".
Albireo
Posts: 68 Joined: 2010-01-12T03:32:23-07:00
Authentication code: 8675309
Post
by Albireo » 2010-01-14T19:53:41-07:00
Hello!
I try to do the examle "Polaroid-like Thumbnails"
http://www.imagemagick.org/Usage/thumbnails/
The original script is:
Code: Select all
convert thumbnail.gif \
-bordercolor white -border 6 \
-bordercolor grey60 -border 1 \
-bordercolor none -background none \
\( -clone 0 -rotate `convert null: -format '%[fx:rand()*30-15]' info:` \) \
\( -clone 0 -rotate `convert null: -format '%[fx:rand()*30-15]' info:` \) \
\( -clone 0 -rotate `convert null: -format '%[fx:rand()*30-15]' info:` \) \
\( -clone 0 -rotate `convert null: -format '%[fx:rand()*30-15]' info:` \) \
-delete 0 -border 100x80 -gravity center \
-crop 200x160+0+0 +repage -flatten -trim +repage \
-background black \( +clone -shadow 60x4+4+4 \) +swap \
-background none -flatten \
poloroid_stack.png
and the converted script (for "DOS"/Windows) was
Code: Select all
convert thumbnail.gif ^
-bordercolor white -border 6 ^
-bordercolor grey60 -border 1 ^
-bordercolor none -background none ^
( -clone 0 -rotate `convert null: -format "%%[fx:rand()*30-15]" info:` ) ^
( -clone 0 -rotate `convert null: -format "%%[fx:rand()*30-15]" info:` ) ^
( -clone 0 -rotate `convert null: -format "%%[fx:rand()*30-15]" info:` ) ^
( -clone 0 -rotate `convert null: -format "%%[fx:rand()*30-15]" info:` ) ^
-delete 0 -border 100x80 -gravity center ^
-crop 200x160+0+0 +repage -flatten -trim +repage ^
-background black ( +clone -shadow 60x4+4+4 ) +swap ^
-background none -flatten ^
poloroid_stack.png
But it doesn't work - I got the following error message:
Code: Select all
convert: invalid argument for option '-rotate': 'convert @ convert.c/Convert eCommand/2238.
Maybe the problem is I don't know to translate the "Grave accent" ` or
the problem is to translate the "Square brackets" [] or....
//Jan
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2010-01-14T20:26:31-07:00
I believe that the expression in `...` (`convert null: -format "%%[fx:rand()*30-15]" info:`) is unix, but don't know how you would convert that to DOS.
You should be able to set up variables for the angles of rotation calculated by the fx expression and then substitute them in place of those unix commands. What Anthony was doing was an inplace angle calculation by substituting that command via a unix trick.
Have a look at
http://www.imagemagick.org/Usage/windows/ Perhaps it can give you some clues how to do that in DOS.
el_supremo
Posts: 1015 Joined: 2005-03-21T21:16:57-07:00
Post
by el_supremo » 2010-01-14T20:40:19-07:00
The problem is with the Grave accents - backquotes. DOS doesn't recognize them in the middle of a command.
However, the FOR command does allow them in one variation of its format. You have to run the for command four times to set four different variables and then use those variables in the main convert command.
Code: Select all
for /F "usebackq" %z IN (`convert null: -format "%[fx:rand()*30-15]" info:`) do set a=%z
for /F "usebackq" %z IN (`convert null: -format "%[fx:rand()*30-15]" info:`) do set b=%z
for /F "usebackq" %z IN (`convert null: -format "%[fx:rand()*30-15]" info:`) do set c=%z
for /F "usebackq" %z IN (`convert null: -format "%[fx:rand()*30-15]" info:`) do set d=%z
convert thumbnail.gif ^
-bordercolor white -border 6 ^
-bordercolor grey60 -border 1 ^
-bordercolor none -background none ^
( -clone 0 -rotate %a ) ^
( -clone 0 -rotate %b ) ^
( -clone 0 -rotate %c ) ^
( -clone 0 -rotate %d ) ^
-delete 0 -border 100x80 -gravity center ^
-crop 200x160+0+0 +repage -flatten -trim +repage ^
-background black ( +clone -shadow 60x4+4+4 ) +swap ^
-background none -flatten ^
poloroid_stack.png
I'm not certain whether it is -rotate %a or -rotate %a% so if the first fails, try the second.
Useful info about the DOS FOR command is at:
http://www.computerhope.com/forhlp.htm
and for all DOS commands see:
http://www.computerhope.com/msdos.htm
Pete
Sorry, my ISP shutdown all personal webspace so my
MagickWand Examples in C is offline.
See my message in
this topic for a link to a zip of all the files.
Albireo
Posts: 68 Joined: 2010-01-12T03:32:23-07:00
Authentication code: 8675309
Post
by Albireo » 2010-01-15T07:42:40-07:00
el_supremo wrote: The problem is with the Grave accents - backquotes. DOS doesn't recognize them in the middle of a command............
Pete
You have right! -
Thank you very much!
This code works and do the same thing as in the example.
Code: Select all
for /F "usebackq" %%z IN (`convert null: -format "%%[fx:rand()*30-15]" info:`) do set a=%%z
for /F "usebackq" %%z IN (`convert null: -format "%%[fx:rand()*30-15]" info:`) do set b=%%z
for /F "usebackq" %%z IN (`convert null: -format "%%[fx:rand()*30-15]" info:`) do set c=%%z
for /F "usebackq" %%z IN (`convert null: -format "%%[fx:rand()*30-15]" info:`) do set d=%%z
convert thumbnail.gif ^
-bordercolor white -border 6 ^
-bordercolor grey60 -border 1 ^
-bordercolor none -background none ^
( -clone 0 -rotate %a% ) ^
( -clone 0 -rotate %b% ) ^
( -clone 0 -rotate %c% ) ^
( -clone 0 -rotate %d% ) ^
-delete 0 -border 100x80 -gravity center ^
-crop 200x160+0+0 +repage -flatten -trim +repage ^
-background black ( +clone -shadow 60x4+4+4 ) +swap ^
-background none -flatten c:\temp\pic\poloroid_stack.png
//Jan