Resize i true color
Jeg har denne kode, som skal resize billeder:<?php
/*
Will generate a pages width of
thumbnailed GIF's and JPG's
from a secified directory. Will work
in a directory with other files in it
with no problems. Part 2. The image
creator.
Aspect ratio is not supported.
Generated: 24/3/03
Author: Rock
*/
// Comments will be throughout
$t_width = 190; // Thumbnail width
$t_height = 145; // Thumbnail height
// get and display jpeg images
if(stristr($QUERY_STRING,".jpg")){
header("Content-type: image/jpeg");
$srcimage = imagecreatefromjpeg($QUERY_STRING);
$destimage = imagecreate($t_width,$t_height);
$width = imageSX($srcimage);
$height = imageSY($srcimage);
imagecopyresized ($destimage,$srcimage,0,0,0,0,$t_width,$t_height,$width,$height);
ImageJPEG($destimage);
ImageDestroy($destimage);
}
/*
//Support for GIF unavailable at this time
elseif(stristr($QUERY_STRING,".gif")){
header("Content-type: image/gif");
$srcimage = imagecreatefromgif($QUERY_STRING);
$destimage = imagecreate(100,100);
$width = imageSX($srcimage);
$height = imageSY($srcimage);
imagecopyresized ($destimage,$srcimage,0,0,0,0,$t_width,$t_height,$width,$height);
ImageGIF($destimage);
ImageDestroy($destimage);
}
*/
// on a problem geneterate an image with ERROR in it
else {
$im = imagecreate(100,100);
$blue = imagecolorallocate($im,0,0,200);
$red = imagecolorallocate($im,255,0,0);
imagestring($im,2,2,5,"ERROR",$red);
imageGIF($im);
imagedestroy($im);
}
?>
Problemet er at den ikke resizer i True Color, så billederne bliver underlige i farven!
Hvordan ændrer jeg dette?!
