Hello,
I have been using an image resize function to create thumbnails when an image is saved. My server recently upgraded to PHP 4.3.2.
The function still works, but the colors are all wacked.
Here is an example of the problem:
Original:
Resized:

Here is the code I use:
//Resize and create thumbnail
if ($data[type]=='.jpg'){
if (!file_exists($path))
$this->returnError("THM: Failed to open original \"$path\"",1);
$thm_size = $this->scalePhoto($data[width],$data[height],101,131);
$dest = imagecreatetruecolor($thm_size[width], $thm_size[height]);
if (!imagejpeg ($dest, '/home/users/web/b2014/dejahue/temp.jpg'))
$this->returnError("THM: Failed to create temp image",1);
imagedestroy ($dest);
$img_thm = imagecreatefromjpeg('/home/users/web/b2014/dejahue/temp.jpg');
$img_org = imagecreatefromjpeg($path);
imagecopyresampled($img_thm, $img_org, 0, 0, 0, 0, $thm_size[width], $thm_size[height], $data[width], $data[height]);
$img_thm2 = imagecreate($thm_size[width]-1,$thm_size[height]-1);
imagecopy ($img_thm2, $img_thm, 0,0,0,0,$thm_size[width]-1,$thm_size[height]-1);
imagejpeg ($img_thm2, $thm_path);
imagedestroy($img_thm);
imagedestroy($img_org);
unlink('/home/users/web/b2014/dejahue/temp.jpg');
} else {
$thm_size[width]=$data[width];
$thm_size[height]=$data[height];
if(!(@copy($pPhoto, $thm_path))) $this->returnError("Product photo upload failed to location \"$path\"",1);
}
Could anyone help me with this one?
Thanks!