note 88436 added to function.imagerotate
| From: | KaeCyphet at osu1 dot php dot net | Date: | Fri, 23 Jan 2009 21:50:11 +0000 |
| Subject: | note 88436 added to function.imagerotate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-149717@lists.php.net to get a copy of this message | ||
To solve that annoying problem of having to install a pre-compiled version of GD just to get
imagerotate working.
here is an open source solution.
uses the standard stuff included in php when you uncomment 'extension=php_gd2.dll' in the
php.ini file and there ya go!
Useage:
<?php
$im = imagecreatefromjpeg('test.jpg');
header('Content-type: image/jpg');
imagejpeg(rotate_right90($im));
imagedestroy($im);
?>
'=================================
<?php
function rotate_right90($im)
{
$wid = imagesx($im);
$hei = imagesy($im);
$im2 = imagecreatetruecolor($hei,$wid);
for($i = 0;$i < $wid; $i++)
{
for($j = 0;$j < $hei; $j++)
{
$ref = imagecolorat($im,$i,$j);
imagesetpixel($im2,$hei - $j,$i,$ref);
}
}
return $im2;
}
function rotate_left90($im)
{
$wid = imagesx($im);
$hei = imagesy($im);
$im2 = imagecreatetruecolor($hei,$wid);
for($i = 0;$i < $wid; $i++)
{
for($j = 0;$j < $hei; $j++)
{
$ref = imagecolorat($im,$i,$j);
imagesetpixel($im2,$j, $wid - $i,$ref);
}
}
return $im2;
}
function mirror($im)
{
$wid = imagesx($im);
$hei = imagesy($im);
$im2 = imagecreatetruecolor($wid,$hei);
for($i = 0;$i < $wid; $i++)
{
for($j = 0;$j < $hei; $j++)
{
$ref = imagecolorat($im,$i,$j);
imagesetpixel($im2,$wid - $i,$j,$ref);
}
}
return $im2;
}
function flip($im)
{
$wid = imagesx($im);
$hei = imagesy($im);
$im2 = imagecreatetruecolor($wid,$hei);
for($i = 0;$i < $wid; $i++)
{
for($j = 0;$j < $hei; $j++)
{
$ref = imagecolorat($im,$i,$j);
imagesetpixel($im2,$i,$hei - $j,$ref);
}
}
return $im2;
}
?>
----
Server IP: 208.69.120.35
Probable Submitter: 24.18.188.178
----
Manual Page -- http://www.php.net/manual/en/function.imagerotate.php
Edit -- https://master.php.net/note/edit/88436
Del: integrated -- https://master.php.net/note/delete/88436/integrated
Del: useless -- https://master.php.net/note/delete/88436/useless
Del: bad code -- https://master.php.net/note/delete/88436/bad+code
Del: spam -- https://master.php.net/note/delete/88436/spam
Del: non-english -- https://master.php.net/note/delete/88436/non-english
Del: in docs -- https://master.php.net/note/delete/88436/in+docs
Del: other reasons-- https://master.php.net/note/delete/88436
Reject -- https://master.php.net/note/reject/88436
Search -- https://master.php.net/manage/user-notes.php