Create borders from texture images
Create borders from texture images
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
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
Last edited by kostya572 on 2017-06-23T19:22:29-07:00, edited 1 time in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Create borders from texture images
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/
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
Thank you for explaining the rules, I have updated my question.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/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Create borders from texture images
try this:
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
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
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
Thank you, it worksfmw42 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
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
Hi, fmw42fmw42 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
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
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Create borders from texture images
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
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Create borders from texture images
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...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
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
Thank you guys, you helped me a lot, everything works perfectly