How can I stroke an image with a 1px border, like this image: http://img.photobucket.com/albums/v635/sfg/miss0042.png
I could splice it in all four directions with convert, but I want to do it for many files at once so to my understanding that's only possible with mogrify which gives me a "unrecognized option 'splice' " error.
Stroking
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Stroking
convert image -bordercolor black -border 1 result
will add a 1 pixel border outside the bounds of the image
see http://www.imagemagick.org/Usage/crop/ and esp http://www.imagemagick.org/Usage/crop/#border
will add a 1 pixel border outside the bounds of the image
see http://www.imagemagick.org/Usage/crop/ and esp http://www.imagemagick.org/Usage/crop/#border
Re: Stroking
Not working. It fills all the transparency with black. I tried -background none but that has no effect.
The files are transparent .png so I need to keep that transparency.
The files are transparent .png so I need to keep that transparency.
Re: Stroking
And isn't there a way to use splice with mogrify? Because that would solve this problem just fine.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Stroking
don't think splice works with mogrify. you can try. I am not sure. mogrify is old and does not support all functions that convert does.
try
convert image -channel rgba -alpha on -bordercolor black -border 1 result
try
convert image -channel rgba -alpha on -bordercolor black -border 1 result
Re: Stroking
Nope, still the same.
And if mogrify is old, is there any other way to convert a batch of images and replacing the old files like mogrify does?
And if mogrify is old, is there any other way to convert a batch of images and replacing the old files like mogrify does?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Stroking
other than scripting a bunch of images or using wild cards, no other similar way to mogrify and I am not too sure about how to use wild cards to do a sequence of images.
try
convert miss0042.png -alpha off -bordercolor black -border 10 -alpha on miss0042_b10.png
for multiple images, you can try
convert image1.png image2.png .... alpha off -bordercolor black -border 10 -alpha on miss0042_b10_%d.png
or if all the files are in the same directory and no other files,
convert miss*.png -alpha off -bordercolor black -border 10 -alpha on miss_b10_%d.png
or
convert *.png -alpha off -bordercolor black -border 10 -alpha on miss_b10_%d.png
not too sure about the latter two
The other way is to write a script and loop over all you images.
see for example:
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-7.html
http://www.cyberciti.biz/faq/bash-for-loop/
http://www.cyberciti.biz/faq/bash-while-loop/
http://hacktux.com/bash/file
http://aplawrence.com/Basics/bash_looping.html
try
convert miss0042.png -alpha off -bordercolor black -border 10 -alpha on miss0042_b10.png
for multiple images, you can try
convert image1.png image2.png .... alpha off -bordercolor black -border 10 -alpha on miss0042_b10_%d.png
or if all the files are in the same directory and no other files,
convert miss*.png -alpha off -bordercolor black -border 10 -alpha on miss_b10_%d.png
or
convert *.png -alpha off -bordercolor black -border 10 -alpha on miss_b10_%d.png
not too sure about the latter two
The other way is to write a script and loop over all you images.
see for example:
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-7.html
http://www.cyberciti.biz/faq/bash-for-loop/
http://www.cyberciti.biz/faq/bash-while-loop/
http://hacktux.com/bash/file
http://aplawrence.com/Basics/bash_looping.html
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Stroking
Just did a test and this seems to work with mogrify
I put 3 copies of your image into a directory test1 and created an empty directory test2. The following processes each image in test1 and puts the result with the border around it in directory test2
cd test1
mogrify -path /Users/fred/test2 -format png -alpha off -bordercolor black -border 10 -alpha on *.png
I put 3 copies of your image into a directory test1 and created an empty directory test2. The following processes each image in test1 and puts the result with the border around it in directory test2
cd test1
mogrify -path /Users/fred/test2 -format png -alpha off -bordercolor black -border 10 -alpha on *.png
Re: Stroking
Aha! Perfect! Thank you very much!