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
bfriesen simple.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-help lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gra
phicsmagick-help
|