note 77033 added to function.imagerotate

From: Date: Sat, 11 Aug 2007 23:06:07 +0000
Subject: note 77033 added to function.imagerotate
Groups: php.notes 
Request: Send a blank email to php-notes+get-129415@lists.php.net to get a copy of this message
imagerotate seems to be very fussy about handling transparency when copymerging onto another image. You can use the GD library's other transparency features to cover up the fact imagerotate gets it wrong HOWEVER it will only work if the top-left corner of the image is transparent at all rotations, so make the image a little bigger than it needs to be. This has been tested with png32 but does not work entirely for png8, as a phenomena creates noise around the rotated image. <?php $imgImage = imagecreatefrompng("image.png"); $colBlack = imagecolorallocate($imgImage, 0, 0, 0); $imgImage = imagerotate($imgImage, 360 - $intHeading, 0); imagefill($imgImage, 0, 0, $colBlack); imagecolortransparent($imgImage, $colBlack); imagecopymerge($imgOriginalImage , $imgImage, $intX, $intY, 0, 0, $intHeight, $intWidth, 100); imagedestroy($imgImage); ?> Note. $intHeading is in degrees clockwise :) ---- Server IP: 69.147.83.197 Probable Submitter: 90.202.184.61 ---- Manual Page -- http://www.php.net/manual/en/function.imagerotate.php Edit -- https://master.php.net/note/edit/77033 Del: integrated -- https://master.php.net/note/delete/77033/integrated Del: useless -- https://master.php.net/note/delete/77033/useless Del: bad code -- https://master.php.net/note/delete/77033/bad+code Del: spam -- https://master.php.net/note/delete/77033/spam Del: non-english -- https://master.php.net/note/delete/77033/non-english Del: in docs -- https://master.php.net/note/delete/77033/in+docs Del: other reasons-- https://master.php.net/note/delete/77033 Reject -- https://master.php.net/note/reject/77033 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#129415) next »