note 85171 deleted from function.imagecopy by felipe
| From: | felipe@php.net | Date: | Wed, 20 Aug 2008 02:51:40 +0000 |
| Subject: | note 85171 deleted from function.imagecopy by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-143662@lists.php.net to get a copy of this message | ||
Note Submitter: cbl25
----
Here is a simple function to rotate a non-square image 90 degrees clockwise.
<?php
function rotateImage($imageResource)
{
$width = imagesx($imageResource);
$height = imagesy($imageResource);
$side = $width > $height ? $width : $height;
$squareImage = imagecreatetruecolor($side, $side);
imagecopy($squareImage,$imageResource,0,0,0,0,$width,$height);
$squareImage = imagerotate($squareImage,270,0,-1);
$imageResource = $squareImage;
$imageResource = imagecreatetruecolor($height, $width);
imagecopy($imageResource,$squareImage,0,0,0,0,$height,$width);
return $imageResource;
}
?>