note 121938 added to function.imagesetinterpolation
| From: | shaun at slickdesign dot com dot au | Date: | Wed, 29 Nov 2017 08:27:19 +0000 |
| Subject: | note 121938 added to function.imagesetinterpolation | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-209246@lists.php.net to get a copy of this message | ||
Setting the interpolation does not carry through to any images created by imageaffine() or
imagerotate(). It defaults to IMG_BILINEAR_FIXED and would need to be set on each generated image as
required.
<?php
imagesetinterpolation( $image, IMG_NEAREST_NEIGHBOUR );
// Rotated using IMG_NEAREST_NEIGHBOUR
$rotated = imagerotate( $image, 45, $transparent );
// Rotated using IMG_BILINEAR_FIXED
$rotated_again = imagerotate( $rotated, 45, $transparent );
?>
Setting the interpolation to IMG_NEAREST_NEIGHBOUR can help to preserve details and prevent sampling
issues when rotating an image at 90 degree increments, including when rotating clockwise.
<?php
// Rotated image can appear blurred and on a slight angle.
$rotated = imagerotate( $image, -360, $transparent );
// Similar to starting Image although it may still show a background or be on a slight angle.
imagesetinterpolation( $image, IMG_NEAREST_NEIGHBOUR );
$rotated = imagerotate( $image, -360, $transparent );
?>
----
Server IP: 208.43.231.9
Probable Submitter: 211.26.34.121
----
Manual Page -- http://php.net/manual/en/function.imagesetinterpolation.php
Edit -- https://master.php.net/note/edit/121938
Del: integrated -- https://master.php.net/note/delete/121938/integrated
Del: useless -- https://master.php.net/note/delete/121938/useless
Del: bad code -- https://master.php.net/note/delete/121938/bad+code
Del: spam -- https://master.php.net/note/delete/121938/spam
Del: non-english -- https://master.php.net/note/delete/121938/non-english
Del: in docs -- https://master.php.net/note/delete/121938/in+docs
Del: other reasons-- https://master.php.net/note/delete/121938
Reject -- https://master.php.net/note/reject/121938
Search -- https://master.php.net/manage/user-notes.php