note 119184 added to imagick.rotateimage
| From: | Anonymous | Date: | Sun, 17 Apr 2016 10:43:40 +0000 |
| Subject: | note 119184 added to imagick.rotateimage | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-205249@lists.php.net to get a copy of this message | ||
The degrees for imagick and gd is difference!
GD > rotate 90 means counter clockwise.
Imagick > rotate 90 means clockwise.
GD 90 = Imagick 270 or Imagick 90 = GD 270.
Use this function.
<?php
function calculateCounterClockwise($value)
{
if ($value == 0 || $value == 180) {
return $value;
}
if ($value < 0 || $value > 360) {
$value = 90;
}
$total_degree = 360;
$output = intval($total_degree-$value);
return $output;
}// calculateCounterClockwise
echo '1 = '.calculateCounterClockwise(1).'<br>';
echo '90 = '.calculateCounterClockwise(90).'<br>';
echo '270 = '.calculateCounterClockwise(270).'<br>';
echo '359 = '.calculateCounterClockwise(359).'<br>';
echo '360 = '.calculateCounterClockwise(360).'<br>';
?>
test results:
1 = 359
90 = 270
270 = 90
359 = 1
360 = 0
----
Server IP: 72.52.91.14
Probable Submitter: 110.171.248.148 (proxied: 110.171.248.148)
----
Manual Page -- http://php.net/manual/en/imagick.rotateimage.php
Edit -- https://master.php.net/note/edit/119184
Del: integrated -- https://master.php.net/note/delete/119184/integrated
Del: useless -- https://master.php.net/note/delete/119184/useless
Del: bad code -- https://master.php.net/note/delete/119184/bad+code
Del: spam -- https://master.php.net/note/delete/119184/spam
Del: non-english -- https://master.php.net/note/delete/119184/non-english
Del: in docs -- https://master.php.net/note/delete/119184/in+docs
Del: other reasons-- https://master.php.net/note/delete/119184
Reject -- https://master.php.net/note/reject/119184
Search -- https://master.php.net/manage/user-notes.php