List Info

Thread: Black border in the transparent image




Black border in the transparent image
user name
2007-03-30 17:40:26
Hi Bob and all,

When I resize and rotate an image, a black border always appears in the image.

Here is the command line I use:
gm convert -resize 80% -background transparent -rotate 60 source.png result.png

It does not matter which image I use, as long as the background is transparent and the image is resized.

In addition, the black border also appears in the command line:
gm convert -size 500x500 -background none -fill yellow -pointsize 72 label:Testing test.gif

How can I avoid it?

Any help would be appreciated.

Thank you.

Geroge


Re: Black border in the transparent image
country flaguser name
United States
2007-03-30 20:17:28
On Fri, 30 Mar 2007, George K wrote:

> Hi Bob and all,
>
> When I resize and rotate an image, a black border
always appears in the
> image.
>
> Here is the command line I use:
> gm convert -resize 80% -background transparent -rotate
60 source.png
> result.png
>
> It does not matter which image I use, as long as the
background is
> transparent and the image is resized.

This is a very difficult problem to solve and in fact I am
not sure 
how to best solve it.  The problem is that 'transparent'
represents a 
single transparent color (transparent black), but due to
anti-aliasing 
of the object-edges (with 'black') a new color is generated
which does 
not match the transparent color exactly so the black shows. 
If the 
anti-aliasing algorithm noticed that the pixel was
transparent then it 
could replace the black color with the pixel foreground
color 
(respecting only the transparency), but unfortunately there
are no 
such smarts. Thesholding the opacity (matte) channel can
help a little 
bit (convert more black pixels into transparent pixels) but
it will 
never be completely right and it will destroy the smooth
edges.

While it does not really solve the problem, a workaround is
to use a 
more pleasant/suitable transparent background color.  For
example, you 
can use

   gm convert -resize 80% -background '#FFFF' -rotate 60
source.png result.png

to use a transparent white if you know that the result will
be 
composited on top of a white background.  The last 'F'
indicates 
complete transparency.  If you need more precision you can
use two or 
three digits for each color component.

Bob
======================================
Bob Friesenhahn
bfriesensimple.dallas.tx.us, http://w
ww.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMag
ick.org/


------------------------------------------------------------
-------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the
chance to share your
opinions on IT & business topics through brief
surveys-and earn cash
http://www.techsay.com/default.
php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Graphicsmagick-help mailing list
Graphicsmagick-helplists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gra
phicsmagick-help

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )