note 96840 deleted from function.imagerotate by danbrown
| From: | danbrown@php.net | Date: | Thu, 18 Mar 2010 16:48:36 +0000 |
| Subject: | note 96840 deleted from function.imagerotate by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-167173@lists.php.net to get a copy of this message | ||
Note Submitter: witold [dot] zywica [at] gmail [dot] com
----
I corected the code of kmrohe at letsco dot de. In my case his code converted white to blue. In my
code it is fixed.
function rotateImage($image) {
$width = imagesx($image);
$height = imagesy($image);
$newImage = imagecreatetruecolor($height, $width);
imagealphablending($newImage, false);
imagesavealpha($newImage, true);
for($w=0; $w<$width; $w++){
for($h=0; $h<$height; $h++) {
$ref = imagecolorat($image, $w, $h);
$colors = imagecolorsforindex($image, $ref);
$col = imagecolorallocate($newImage, $colors['red'], $colors['green'],
$colors['blue']);
imagesetpixel($newImage, $h, ($width-1)-$w,$col);
}
}
return $newImage;
}