Help needed on Framing script from examples.

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
creekpeanut
Posts: 25
Joined: 2012-08-14T09:36:42-07:00
Authentication code: 67789

Help needed on Framing script from examples.

Post by creekpeanut »

I am testing the script from
http://www.imagemagick.org/Usage/thumbnails/#self_frame

When I run the script from the shell "bash eframe.sh" It will render the new image but not the frame.
Any help would be great.

Files
http://www.mediafire.com/?2nwtm98n4xdv0qm

I am using IM 6.6.9-7 on Unbuntu 12.04.

Here is the script, eframe.sh


image=tempnew.png
image_w=`convert $image -format %w info:`
image_h=`convert $image -format %h info:`

top="edge_images/goldthin_top.png"
btm="edge_images/goldthin_btm.png"

width=`convert $top -format %h info:`
length=`convert $top -format %w info:`



# Size of the new image ( using BASH integer maths)
new_size=$(($image_w+$width*2))x$(($image_h+$width*2))


# IM options to read a 'randomly rolled' version for the edge pieces
lft="( $top -roll +$(($RANDOM % $length))+0 -transpose )"
rht="( $btm -roll +$(($RANDOM % $length))+0 -transpose )"

# IM options to 'randomly rolled' the top and bottom pieces
top="( $top -roll +$(($RANDOM % $length))+0 )"
btm="( $btm -roll +$(($RANDOM % $length))+0 )"

# Frame the image in a single IM command....
convert -page +$width+$width $image +page -matte \
\( +clone -compose Dst -bordercolor none -frame ${width}x$width+$width \
-fill none -draw "matte 0,0 replace" \
-flip -draw "matte 0,0 replace" -flip \) \
\( $top $btm -append -background none -splice 0x${image_h}+0+$width \
-write mpr:horz +delete -size $new_size tile:mpr:horz +size \
-clone 1 -compose DstOut -composite \) \
\( $lft $rht +append -background none -splice ${image_w}x0+$width+0 \
-write mpr:vert +delete -size $new_size tile:mpr:vert +size \
-clone 1 -compose DstIn -composite \) \
-delete 1 -compose Over -mosaic framed_script.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help needed on Framing script from examples.

Post by fmw42 »

lft="( $top -roll +$(($RANDOM % $length))+0 -transpose )"
rht="( $btm -roll +$(($RANDOM % $length))+0 -transpose )"

# IM options to 'randomly rolled' the top and bottom pieces
top="( $top -roll +$(($RANDOM % $length))+0 )"
btm="( $btm -roll +$(($RANDOM % $length))+0 )"

IM parenthesis processing on unix requires \( and \). But I am not sure you can to that in a variable? I have not tried it.
creekpeanut
Posts: 25
Joined: 2012-08-14T09:36:42-07:00
Authentication code: 67789

Re: Help needed on Framing script from examples.

Post by creekpeanut »

Here is the modified code but still same issue.

No frame. :(
image=tempnew.png
image_w=`convert $image -format %w info:`
image_h=`convert $image -format %h info:`

top="edge_images/goldthin_top.png"
btm="edge_images/goldthin_btm.png"

width=`convert $top -format %h info:`
length=`convert $top -format %w info:`



# Size of the new image ( using BASH integer maths)
new_size=$(($image_w+$width*2))x$(($image_h+$width*2))



# Frame the image in a single IM command....
convert -page +$width+$width $image +page -matte \
\( +clone -compose Dst -bordercolor none -frame ${width}x$width+$width \
-fill none -draw "matte 0,0 replace" \
-flip -draw "matte 0,0 replace" -flip \) \
\( \
\( $top -roll +$(($RANDOM % $length))+0 \) \
\( $btm -roll +$(($RANDOM % $length))+0 \) \
-append -background none -splice 0x${image_h}+0+$width \
-write mpr:horz +delete -size $new_size tile:mpr:horz +size \
-clone 1 -compose DstOut -composite \) \
\( \
\( $top -roll +$(($RANDOM % $length))+0 -transpose \) \
\( $btm -roll +$(($RANDOM % $length))+0 -transpose \) \
+append -background none -splice ${image_w}x0+$width+0 \
-write mpr:vert +delete -size $new_size tile:mpr:vert +size \
-clone 1 -compose DstIn -composite \) \
-delete 1 -compose Over -mosaic framed_script.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help needed on Framing script from examples.

Post by fmw42 »

best thing I can suggest is put +write imageX.png where X=1,2,... after each step where you create something new and then look at each of these images to see where it is going wrong.
Post Reply