|
Posted by Trevor on 12/23/05 01:12
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 = imagecreatetruecolor(200, $height*$ratio);
$image = imagecreatefromgif($_FILES['imagefile']['tmp_name']);
$newimage = imagecopyresampled($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 = imagecreatetruecolor($width*$ratio, 134);
$image = imagecreatefromgif($_FILES['imagefile']['tmp_name']);
$newimage = imagecopyresampled($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";
}
Navigation:
[Reply to this message]
|