How to preserve transparency when resizing PNG using Perl and GD
问题 This is the code i'm using: !/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,