note 85171 modified in function.imagecopy by thiago
| From: | thiago@php.net | Date: | Mon, 18 Aug 2008 21:28:40 +0000 |
| Subject: | note 85171 modified in function.imagecopy by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-143609@lists.php.net to get a copy of this message | ||
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;
}
?>
--was--
Here is a simple function to rotate a non-square image 90 degrees clockwise.
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;
}
http://php.net/manual/en/function.imagecopy.php