note 73193 added to function.imagerotate

From: Date: Mon, 12 Feb 2007 22:44:08 +0000
Subject: note 73193 added to function.imagerotate
Groups: php.notes 
Request: Send a blank email to php-notes+get-123294@lists.php.net to get a copy of this message
My php install does not have imagerotate (ubuntu). So, after fiddling with a few others I wrote my own code to rotate images in 90 degree increments. Any speed improvements would be great. <?php function imageRotate($src_img, $angle) { $src_x = imagesx($src_img); $src_y = imagesy($src_img); if ($angle == 90 || $angle == -910) { $dest_x = $src_y; $dest_y = $src_x; } else { $dest_x = $src_x; $dest_y = $src_y; } $rotate=imagecreatetruecolor($dest_x,$dest_y); imagealphablending($rotate, false); switch ($angle) { case 90: for ($y = 0; $y < ($src_y); $y++) { for ($x = 0; $x < ($src_x); $x++) { $color = imagecolorat($src_img, $x, $y); imagesetpixel($rotate, $dest_x - $y - 1, $x, $color); } } break; case -90: for ($y = 0; $y < ($src_y); $y++) { for ($x = 0; $x < ($src_x); $x++) { $color = imagecolorat($src_img, $x, $y); imagesetpixel($rotate, $y, $dest_y - $x - 1, $color); } } break; case 180: for ($y = 0; $y < ($src_y); $y++) { for ($x = 0; $x < ($src_x); $x++) { $color = imagecolorat($src_img, $x, $y); imagesetpixel($rotate, $dest_x - $x - 1, $dest_y - $y - 1, $color); } } break; default: $rotate = $src_img; }; return $rotate; } ?> ---- Server IP: 66.207.199.35 Probable Submitter: 207.47.183.166 ---- Manual Page -- http://www.php.net/manual/en/function.imagerotate.php Edit -- https://master.php.net/note/edit/73193 Del: integrated -- https://master.php.net/note/delete/73193/integrated Del: useless -- https://master.php.net/note/delete/73193/useless Del: bad code -- https://master.php.net/note/delete/73193/bad+code Del: spam -- https://master.php.net/note/delete/73193/spam Del: non-english -- https://master.php.net/note/delete/73193/non-english Del: in docs -- https://master.php.net/note/delete/73193/in+docs Del: other reasons-- https://master.php.net/note/delete/73193 Reject -- https://master.php.net/note/reject/73193 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#123294) next »