note 73446 added to function.imagerotate

From: Date: Fri, 23 Feb 2007 15:21:06 +0000
Subject: note 73446 added to function.imagerotate
Groups: php.notes 
Request: Send a blank email to php-notes+get-123771@lists.php.net to get a copy of this message
function rotate($degrees) { if(function_exists("imagerotate")) $this->image = imagerotate($this->image, $degrees, 0); else { function imagerotate($src_img, $angle) { $src_x = imagesx($src_img); $src_y = imagesy($src_img); if ($angle == 180) { $dest_x = $src_x; $dest_y = $src_y; } elseif ($src_x <= $src_y) { $dest_x = $src_y; $dest_y = $src_x; } elseif ($src_x >= $src_y) { $dest_x = $src_y; $dest_y = $src_x; } $rotate=imagecreatetruecolor($dest_x,$dest_y); imagealphablending($rotate, false); switch ($angle) { case 270: 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; } $this->image = imagerotate($this->image, $degrees); } } This one works better than the one below from the 12th February and if the faster function is available it will take that. It is still not optimized but turning pictures works better.. ---- Server IP: 217.13.201.10 Probable Submitter: 84.133.77.109 ---- Manual Page -- http://www.php.net/manual/en/function.imagerotate.php Edit -- https://master.php.net/note/edit/73446 Del: integrated -- https://master.php.net/note/delete/73446/integrated Del: useless -- https://master.php.net/note/delete/73446/useless Del: bad code -- https://master.php.net/note/delete/73446/bad+code Del: spam -- https://master.php.net/note/delete/73446/spam Del: non-english -- https://master.php.net/note/delete/73446/non-english Del: in docs -- https://master.php.net/note/delete/73446/in+docs Del: other reasons-- https://master.php.net/note/delete/73446 Reject -- https://master.php.net/note/reject/73446 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#123771) next »