6
kullanarak PNG boyutlandırma zaman şeffaflığı korumak için:Bu i kullanıyorum kodudur Perl ve GD
!/usr/bin/perl
use GD;
sub resize
{
my ($inputfile, $width, $height, $outputfile) = @_;
my $gdo = GD::Image->new($inputfile);
## Begin resize
my $k_h = $height/$gdo->height;
my $k_w = $width/$gdo->width;
my $k = ($k_h < $k_w ? $k_h : $k_w);
$height = int($gdo->height * $k);
$width = int($gdo->width * $k);
## The tricky part
my $image = GD::Image->new($width, $height, $gdo->trueColor);
$image->transparent($gdo->transparent());
$image->copyResampled($gdo, 0, 0, 0, 0, $width, $height, $gdo->width, $gdo->height);
## End resize
open(FH, ">".$outputfile);
binmode(FH);
print FH $image->png();
close(FH);
}
resize("test.png", 300, 300, "tested.png");
çıkış görüntüsü siyah bir arka plan vardır ve tüm alfa kanalları kaybolur. Bu görüntü kullanılarak
bi'şey: http://i54.tinypic.com/33ykhad.png
Bu sonuç:
http://i54.tinypic.com/15nuotf.png Ben alfa tüm kombinasyonları denedi() ve transparan() vb şeyler bunların hiçbiri çalıştı ....
Bu konuda bana yardımcı olun.
olası yinelenen [PNG resim saydamlık PHP'nin GDlib imagecopyresampled kullanırken korunmuş edilebilir mi?] (Http://stackoverflow.com/questions/32243/can-png-image-transparency-be -preserved-zaman kullanan-phps-GDlib-imagecopyresampled) – daxim