45 degree frame joints

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
User avatar
Draoidh
Posts: 69
Joined: 2012-07-03T11:29:44-07:00
Authentication code: 13
Location: soon to be independent Scotland

45 degree frame joints

Post by Draoidh »

Having worked through this user manual example, here's a slightly easier way to frame the image:

Image

fill, turn, fill, turn, ... :

Code: Select all

convert frame_template.gif \
-tile blackthin_top.gif -draw 'color 1,0 floodfill' -rotate 90 \
-tile blackthin_btm.gif -draw 'color 1,0 floodfill' -rotate 90 \
-tile blackthin_top.gif -draw 'color 1,0 floodfill' -rotate 90 \
-tile blackthin_btm.gif -draw 'color 1,0 floodfill' -rotate 90 \
-gravity center thumbnail.gif -composite frame_filled.gif
I say easier because it doesn't require you to calculate offsets. That means this part of the example code can be copied and works with images of any size. And if you use it in a script you don't need to script the offset calculations.

For this to work you will need to flip the bottom/right edge frame used in the example prior to using it:
Image
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: 45 degree frame joints

Post by anthony »

That is good, but the order of the edge elements are wrong.
The top edge image is used for the top and left edges, not the top and bottom edges.
It also need the bottom edge image to be flipped upside down to layer it correctly.

Get the order right and the edge image flipped, and will work very well for the thin black frame

However if you used rotates with the detailed gold frame, the highlight/shadow effects of internal detail will be wrong.
That is why transposes are used.

Hmm rotate the bottom edge...

Code: Select all

convert goldthin_btm.png -rotate 180 goldthin_btm2.png
now generate and fill the frame.

Code: Select all

convert thumbnail.gif -matte -bordercolor none \
            -compose Dst -frame 25x25+25 \
            -tile goldthin_top.png \
            -draw 'color 1,0 floodfill' -transpose -draw 'color 1,0 floodfill' \
            -transverse -tile goldthin_btm2.png \
            -draw 'color 1,0 floodfill' -transpose -draw 'color 1,0 floodfill' \
            -transverse    frame_gold.png
The only thing missing from this is some randomized offsets to remove some of the artifical look with such a detailed frame... very nice.

It will certainly make the framing examples less complex.

Here is the example I have now added to IM examples, which avoids intermediate images.

Code: Select all

  convert thumbnail.gif                -write mpr:image    +delete \
          goldthin_top.png             -write mpr:edge_top +delete \
          goldthin_btm.png -rotate 180 -write mpr:edge_btm +delete \
          \
          mpr:image -alpha set -bordercolor none \
          -compose Dst -frame 25x25+25  -compose over \
          \
          -transverse  -tile mpr:edge_btm \
          -draw 'color 1,0 floodfill' -transpose -draw 'color 1,0 floodfill' \
          -transverse  -tile mpr:edge_top \
          -draw 'color 1,0 floodfill' -transpose -draw 'color 1,0 floodfill' \
          \
          mpr:image -gravity center -composite    frame_gold.png
Image
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
creekpeanut
Posts: 25
Joined: 2012-08-14T09:36:42-07:00
Authentication code: 67789

Re: 45 degree frame joints

Post by creekpeanut »

Thank you for the easy update
Post Reply