note 45883 deleted from function.imagerotate by tomsommer
| From: | tomsommer@php.net | Date: | Wed, 22 Sep 2004 19:30:25 +0000 |
| Subject: | note 45883 deleted from function.imagerotate by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77187@lists.php.net to get a copy of this message | ||
Note Submitter: php at tehmaze dot nl
----
Very high speed 90 degree rotating loop
<?php
$src = imagecreatefromjpeg('src.jpg');
$sx = imagesx($src);
$sy = imagesy($src);
$dst = imagecreatetruecolor($sy,$sx);
imagepalettecopy($dst,$src);
for ($x = 0 ; $x < $sx ; $x++)
for ($y = 0 ; $y < $sy ; $y++)
imagesetpixel($dst,$y,$x,imagecolorat($src,$x,$y));
header("Content-Type: image/jpeg");
imagejpeg($dst);
?>
Or the other direction:
<?php
$src = imagecreatefromjpeg('src.jpg');
$sx = imagesx($src);
$sy = imagesy($src);
$dst = imagecreatetruecolor($sy,$sx);
imagepalettecopy($dst,$src);
for ($x = 0 ; $x < $sx ; $x++)
for ($y = 0 ; $y < $sy ; $y++)
imagesetpixel($dst,$sy - $y - 1,$sx - $x - 1,imagecolorat($src,$x,$y));
header("Content-Type: image/jpeg");
imagejpeg($dst);
?>