Page 1 of 1

Polaroid-like Thumbnails

Posted: 2010-01-14T19:53:41-07:00
by Albireo
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

Re: Polaroid-like Thumbnails

Posted: 2010-01-14T20:26:31-07:00
by fmw42
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.

Re: Polaroid-like Thumbnails

Posted: 2010-01-14T20:40:19-07:00
by el_supremo
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

Re: Polaroid-like Thumbnails

Posted: 2010-01-15T07:42:40-07:00
by Albireo
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