This code is used to resize and then copy a GIF. How do I make it
preserve transparency info?
elseif ($_FILES['imagefile']['type'] == "image/gif") {
list($width, $height, $type, $attr) =
getimagesize($_ FILES['imagefile']['tmp_name']);
if ($width >= $height) {
if ($width > 200) {
$ratio = 200/$width;
$image_p = imagecreatetrue color(200, $height*$ratio) ;
$image = imagecreatefrom gif($_FILES['imagefile']['tmp_name']);
$newimage = imagecopyresamp led($image_p, $image, 0, 0, 0, 0, 200,
$height*$ratio, $width, $height);
imagepng($image _p, "image.png" );
$image = "image.png" ;
} else {
copy ($_FILES['imagefile']['tmp_name'], "image.gif" );
$image = "image.gif" ;
}
} else {
if ($height > 134) {
$ratio = 134/$height;
$image_p = imagecreatetrue color($width*$r atio, 134);
$image = imagecreatefrom gif($_FILES['imagefile']['tmp_name']);
$newimage = imagecopyresamp led($image_p, $image, 0, 0, 0, 0,
$width*$ratio, 134, $width, $height);
imagepng($image _p, "image.png" );
$image = "image.png" ;
} else {
copy ($_FILES['imagefile']['tmp_name'], "image.gif" );
$image = "image.gif" ;
}
preserve transparency info?
elseif ($_FILES['imagefile']['type'] == "image/gif") {
list($width, $height, $type, $attr) =
getimagesize($_ FILES['imagefile']['tmp_name']);
if ($width >= $height) {
if ($width > 200) {
$ratio = 200/$width;
$image_p = imagecreatetrue color(200, $height*$ratio) ;
$image = imagecreatefrom gif($_FILES['imagefile']['tmp_name']);
$newimage = imagecopyresamp led($image_p, $image, 0, 0, 0, 0, 200,
$height*$ratio, $width, $height);
imagepng($image _p, "image.png" );
$image = "image.png" ;
} else {
copy ($_FILES['imagefile']['tmp_name'], "image.gif" );
$image = "image.gif" ;
}
} else {
if ($height > 134) {
$ratio = 134/$height;
$image_p = imagecreatetrue color($width*$r atio, 134);
$image = imagecreatefrom gif($_FILES['imagefile']['tmp_name']);
$newimage = imagecopyresamp led($image_p, $image, 0, 0, 0, 0,
$width*$ratio, 134, $width, $height);
imagepng($image _p, "image.png" );
$image = "image.png" ;
} else {
copy ($_FILES['imagefile']['tmp_name'], "image.gif" );
$image = "image.gif" ;
}
Comment