Page 1 of 1

Create borders from texture images

Posted: 2017-06-23T16:30:12-07:00
by kostya572
IM Version: ImageMagick 6.8.9-9 Q16 x86_64 2017-05-26
Platform: Linux Shell

To create simple borders with hex codes i can use:
convert image.jpg -bordercolor '#000000' -border '50'

But how can i use texture image (texture.jpg) for border instead of hex color with border size 50?

Input image - http://i.piccy.info/i9/fce981a9a39eb4b5 ... iginal.jpg
Texture image - http://i.piccy.info/i9/1c53c04cd234e838 ... exture.jpg
Desired result - http://i.piccy.info/i9/2e3a0fc62948cb94 ... result.jpg

Thank you

Re: Create borders from texture images

Posted: 2017-06-23T18:56:11-07:00
by fmw42
Please always provide your IM version and platform, since syntax differs. Also please post your input image and the desired texture image, so we can show you on your own images. You can post your images to some free hosting service and put the URLs here.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at viewtopic.php?f=1&t=9620

For novices, see

viewtopic.php?f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/

Re: Create borders from texture images

Posted: 2017-06-23T19:24:13-07:00
by kostya572
fmw42 wrote: 2017-06-23T18:56:11-07:00 Please always provide your IM version and platform, since syntax differs. Also please post your input image and the desired texture image, so we can show you on your own images. You can post your images to some free hosting service and put the URLs here.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at viewtopic.php?f=1&t=9620

For novices, see

viewtopic.php?f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
Thank you for explaining the rules, I have updated my question.

Re: Create borders from texture images

Posted: 2017-06-23T19:50:01-07:00
by fmw42
try this:

Code: Select all

convert \
\( original.jpg -bordercolor none -border 50 \) \
\( -clone 0 -tile texture.jpg -draw "color 0,0 reset" \) \
+swap -compose over -composite result.jpg
Image

See:
http://www.imagemagick.org/Usage/basics/#parenthesis
http://www.imagemagick.org/Usage/basics/#clone
http://www.imagemagick.org/Usage/basics/#swap
http://www.imagemagick.org/Usage/canvas/#tile

Re: Create borders from texture images

Posted: 2017-06-24T05:54:11-07:00
by kostya572
fmw42 wrote: 2017-06-23T19:50:01-07:00 try this:

Code: Select all

convert \
\( original.jpg -bordercolor none -border 50 \) \
\( -clone 0 -tile texture.jpg -draw "color 0,0 reset" \) \
+swap -compose over -composite result.jpg
Image

See:
http://www.imagemagick.org/Usage/basics/#parenthesis
http://www.imagemagick.org/Usage/basics/#clone
http://www.imagemagick.org/Usage/basics/#swap
http://www.imagemagick.org/Usage/canvas/#tile
Thank you, it works :)

Re: Create borders from texture images

Posted: 2017-06-27T10:52:03-07:00
by kostya572
fmw42 wrote: 2017-06-23T19:50:01-07:00 try this:

Code: Select all

convert \
\( original.jpg -bordercolor none -border 50 \) \
\( -clone 0 -tile texture.jpg -draw "color 0,0 reset" \) \
+swap -compose over -composite result.jpg
Image

See:
http://www.imagemagick.org/Usage/basics/#parenthesis
http://www.imagemagick.org/Usage/basics/#clone
http://www.imagemagick.org/Usage/basics/#swap
http://www.imagemagick.org/Usage/canvas/#tile
Hi, fmw42

Could you provide me the same solution with oval border?
I've found the solution here - viewtopic.php?t=18126#p69057 but it combines image + texture with exact size

Thank you

Re: Create borders from texture images

Posted: 2017-06-27T11:51:06-07:00
by fmw42

Code: Select all

ww=`convert original.jpg -format "%w" info:`
hh=`convert original.jpg -format "%h" info:`
rx=`convert xc: -format "%[fx:$ww/2]" info:`
ry=`convert xc: -format "%[fx:$hh/2]" info:`
cx=`convert xc: -format "%[fx:$ww/2]" info:`
cy=`convert xc: -format "%[fx:$hh/2]" info:`
echo "$ww $hh $rx $ry"
convert \
\( original.jpg \( -size ${ww}x${hh} xc:black -fill white -draw "translate $cx,$cy ellipse 0,0 $rx,$ry 0,360" \) \
-alpha off -compose copy_opacity -composite \) \
\( -clone 0 -tile texture.jpg -draw "color 0,0 reset" \) \
+swap -compose over -composite result2.jpg
Image

Re: Create borders from texture images

Posted: 2017-06-27T12:05:27-07:00
by GeeMack
kostya572 wrote: 2017-06-27T10:52:03-07:00Could you provide me the same solution with oval border?
I've found the solution here - viewtopic.php?t=18126#p69057 but it combines image + texture with exact size
The solution fmw42 gave above will put an oval frame on your original, keeping the original dimensions. If you want to also add another 50 pixels on each side, you'll need to account for that, too. A command like this works for me using IM 6.7.7-10 from a bash shell prompt...

Code: Select all

IM_VAR=`convert original.jpg -format "%[fx:w/2],%[fx:h/2]" info:`

convert original.jpg -alpha set -bordercolor black \
   \( -clone 0 -fill black -colorize 100 -fill white -draw "ellipse $IM_VAR $IM_VAR 0,360" \) \
   -border 50 \( -tile texture.jpg -clone 0 -draw "color 0,0 reset" \) -insert 0 -composite result.png

Re: Create borders from texture images

Posted: 2017-06-27T14:40:25-07:00
by kostya572
Thank you guys, you helped me a lot, everything works perfectly :)