note 49557 added to function.imagecreatetruecolor

From: Date: Tue, 01 Feb 2005 14:59:16 +0000
Subject: note 49557 added to function.imagecreatetruecolor
Groups: php.notes 
Request: Send a blank email to php-notes+get-84329@lists.php.net to get a copy of this message
i use thist code but i have black background always:( switch($from_type) { case 1: // GIF $srcImage = imageCreateFromGif($sourcefile); break; case 2: // JPG $srcImage = imageCreateFromJpeg($sourcefile); break; case 3: // PNG $srcImage = imageCreateFromPng($sourcefile); break; } if($oh>$ow){ $konst=$oh/$fh; $tempw = $ow/$konst; $temph = $fh; }else if($oh<$ow){ $konst=$ow/$fw; $temph = $oh/$konst; $tempw = $fw;} $tempImage = imageCreateTrueColor($tempw, $temph); $bgColor = imagecolorallocate($tempImage, 255,255,255); imagefilledrectangle($tempImage, 0, 0, $x-1, $y-1, $bgColor); imageAntiAlias($tempImage, true); imagecopyresampled($tempImage, $srcImage, 0, 0, 0, 0, $tempw, $temph, $ow, $oh); // Calculate offsets if($temph > $fh) { $offsety = number_format(($temph/2)-($fh/2), 0); $offsetx = 0; } else if($tempw > $fw) { $offsetx = number_format(($tempw/2)-($fw/2), 0); $offsety = 0; }else { $offsety = 0; $offsetx = number_format(($tempw/2)-($fw/2), 0); } $destImage = imageCreateTrueColor($fw, $fh); $bgColor = imagecolorallocate($destImage, 255,255,255); imagefilledrectangle($destImage, 0, 0, $x-1, $y-1, $bgColor); imagecopyresampled($destImage, $tempImage, 0, 0, $offsetx, $offsety, $fw, $fh, $fw, $fh); imageJpeg($destImage, $destfile, $jpegquality); }; ---- Manual Page -- http://www.php.net/manual/en/function.imagecreatetruecolor.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49557 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49557&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49557&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49557&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49557&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49557&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49557&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84329) next »