-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Description
Description
The following code:
<?php
$gd = imagecreatetruecolor(5000,5000);
imagefill($gd, 0, 0, imagecolorallocate($gd, 255, 255, 255));
$rot = deg2rad(-1);
$a = cos($rot);
$b = sin($rot);
$gdAffine = imageaffine($gd, [$a ,$b, -$b, $a, 0, 0]);
ob_start();
imagejpeg($gdAffine);
$jpg = ob_get_clean();
echo '<img src="data:image/jpg;base64,'.base64_encode($jpg).'">';
$gdRotate = imagerotate($gd, rad2deg(-$rot), 0);
ob_start();
imagejpeg($gdRotate);
$jpg = ob_get_clean();
echo '<img src="data:image/jpg;base64,'.base64_encode($jpg).'">';Resulted in this output:
- This rotates a 5000x5000 canvas by 1 degree using both
imageaffineandimagerotate - This should result in a black triangle at the top of the canvas with a height of
5000*sin(1deg) = 87 pixels - Both methods produce a final canvas of
5087x5087which is the expected size imageaffineproduces a triangle of 87px high ✔imagerotateproduces a triangle of 73px high ❌ (this implies an actual rotation of ~0.83 degrees)- Looking to the right hand side of the top of
imagerotateshows substantial clipping, suggesting the image has been scaled up in some way and the edge pixels lost.
Top left of imageaffine followed by top left of imagerotate:
Top right of imageaffine showing pixels correctly go into edge
Top right of imagerotate showing substantial cropping of pixels along edge.
GD Version: 2.3.3
PHP Version
PHP 8.3.8
Operating System
No response



