Skip Menu |
 

This queue is for tickets about the GD CPAN distribution.

Report information
The Basics
Id: 40525
Status: rejected
Priority: 0/
Queue: GD

People
Owner: Nobody in particular
Requestors: BRUNORC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 2.39
  • 2.41
Fixed in: (no value)



Subject: "transparent" somehow alters color table
Download (untitled) / with headers
text/plain 348b
There is somehow strange behavior while applying transparency to images loaded from JPG/GIF files. To summarize: my $closest = $img->colorClosest( $r, $g, $b ); $img->transparent( $img->colorClosest( $r, $g, $b ) ); # Now $img->transparent == $closest # but $img->transparent != $img->colorClosest( $r, $g, $b ) I'm attaching the failing test.
Subject: transp.t
Download transp.t
text/x-perl 1.2k
use strict; use warnings; use Test::More tests => 10; use_ok('GD'); my $im = GD::Image->newFromGif("class.gif"); $im->transparent( -1 ); is($im->transparent, -1, 'image is not transparent'); my $closest = $im->colorClosest( 24, 53, 62 ); $im->transparent( $im->colorClosest( 24, 53, 62 ) ); ok( $im->transparent == $closest, 'transparency preserves RGB before' ); ok( $im->transparent == $im->colorClosest( 24, 53, 62 ), 'transparency preserves RGB after' ); $im = GD::Image->newFromJpeg("class.jpg"); $im->transparent( -1 ); is($im->transparent, -1, 'image is not transparent'); $closest = $im->colorClosest( 24, 53, 62 ); $im->transparent( $im->colorClosest( 24, 53, 62 ) ); ok( $im->transparent == $closest, 'transparency preserves RGB before' ); ok( $im->transparent == $im->colorClosest( 24, 53, 62 ), 'transparency preserves RGB after' ); $im = GD::Image->newFromJpeg("dupa.jpg"); $im->transparent( -1 ); is($im->transparent, -1, 'image is not transparent'); $closest = $im->colorClosest( 24, 53, 62 ); $im->transparent( $im->colorClosest( 24, 53, 62 ) ); ok( $im->transparent == $closest, 'transparency preserves RGB before' ); ok( $im->transparent == $im->colorClosest( 24, 53, 62 ), 'transparency preserves RGB after' );
Download (untitled) / with headers
text/plain 606b
Yes, this is expected. It changes the alpha entry in the palette of either the given color or current transparent color. This is the logic in libgd for gdImageColorTransparent. if (!im->trueColor) { if((color < -1) || (color >= gdMaxColors)) { return; } if (im->transparent != -1) { im->alpha[im->transparent] = gdAlphaOpaque; } if (color != -1) { im->alpha[color] = gdAlphaTransparent; } } but colorClosest ignores the alpha, colorClosestAlpha would do it. change the sample to is( $im->transparent, $im->colorClosestAlpha( 24, 53, 62, 255 ), "ClosestAlpha" ); -- Reini Urban


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.