note 29817 deleted from function.imagecreatefrompng by victor
| From: | victor@php.net | Date: | Wed, 26 Feb 2003 06:16:55 +0000 |
| Subject: | note 29817 deleted from function.imagecreatefrompng by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-44535@lists.php.net to get a copy of this message | ||
I'm kinda new at php, in fact it's just my second day learning it, and I kicked asp wright
out the door, this language is amazing.
Anyhow, I kinda hava a problem. I know .png comes in high color resolution, but when I upload and
resize it, it fall back to 256 colors. Can I keep it high color resolution, or is that impossible?
If yes, how?
this is the code:
<?
$new_w = 122;
$new_h = 91;
$destination_img = imagecreate($new_w,$new_h);
if ($image_stats[2]=="2") { //RESIZE JPG
$src_img = imagecreatefromjpeg($dir.$newfile);
imagecopyresized($destination_img,$src_img,0,0,0,0,
$new_w,$new_h,imagesx($src_img),imagesy($src_img));
imagejpeg($destination_img, $dir."file.jpg");
} elseif ($image_stats[2]=="3") { //RESIZE PNG
$src_img=imagecreatefrompng($dir.$newfile);
imagecopyresized($destination_img,$src_img,0,0,0,0,
$new_w,$new_h,ImageSX($src_img),ImageSY($src_img));
Imagepng($destination_img, $dir."file.png");
} elseif ($image_stats[2]=="1") { //RESIZE GIF
}
?>
Also is it possible to, let's say, create a png-file from a gif-file?
I'd like to have it, since standard php doesn't support gifs anymore (I mean I get an
error on imagecreatefromgif(...) ).
I know you can change something on the GD, but I don't know if the host I'm gonna put it
on has done that too, and I like to have code that works everywhere. Maybe that way I can kinda
resize gifs too.
If it might help, something that changes the png to a jpg would be sufficient to to solve the first
problem. It's not the format that I have a problem with, it's the color resolution, so if
I could turn a high color resolution .png into a high color resolution .jpg I'd be more then
happy.
thx Dirk (BE)