Page 1 of 1

Stroking

Posted: 2009-12-30T17:52:03-07:00
by sfg
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.

Re: Stroking

Posted: 2009-12-30T17:53:07-07:00
by fmw42
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

Re: Stroking

Posted: 2009-12-30T17:58:31-07:00
by sfg
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.

Re: Stroking

Posted: 2009-12-30T18:53:41-07:00
by sfg
And isn't there a way to use splice with mogrify? Because that would solve this problem just fine.

Re: Stroking

Posted: 2009-12-30T19:44:28-07:00
by fmw42
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

Re: Stroking

Posted: 2009-12-30T19:48:28-07:00
by sfg
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?

Re: Stroking

Posted: 2009-12-30T20:07:42-07:00
by fmw42
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

Re: Stroking

Posted: 2009-12-30T22:24:23-07:00
by fmw42
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

Re: Stroking

Posted: 2009-12-31T08:26:16-07:00
by sfg
Aha! Perfect! Thank you very much!