xref: /PHP-8.0/ext/gd/tests/bug65148.phpt (revision a555cc0b)
1--TEST--
2Bug #65148 (imagerotate may alter image dimensions)
3--SKIPIF--
4<?php
5if (!extension_loaded('gd')) die('skip gd extension is not available');
6?>
7--FILE--
8<?php
9
10$interpolations = array(
11    'IMG_BELL' => IMG_BELL,
12    'IMG_BESSEL' => IMG_BESSEL,
13    'IMG_BICUBIC' => IMG_BICUBIC,
14    'IMG_BICUBIC_FIXED' => IMG_BICUBIC_FIXED,
15    'IMG_BILINEAR_FIXED' => IMG_BILINEAR_FIXED,
16    'IMG_BLACKMAN' => IMG_BLACKMAN,
17    'IMG_BOX' => IMG_BOX,
18    'IMG_BSPLINE' => IMG_BSPLINE,
19    'IMG_CATMULLROM' => IMG_CATMULLROM,
20    'IMG_GAUSSIAN' => IMG_GAUSSIAN,
21    'IMG_GENERALIZED_CUBIC' => IMG_GENERALIZED_CUBIC,
22    'IMG_HERMITE' => IMG_HERMITE,
23    'IMG_HAMMING' => IMG_HAMMING,
24    'IMG_HANNING' => IMG_HANNING,
25    'IMG_MITCHELL' => IMG_MITCHELL,
26    'IMG_POWER' => IMG_POWER,
27    'IMG_QUADRATIC' => IMG_QUADRATIC,
28    'IMG_SINC' => IMG_SINC,
29    'IMG_NEAREST_NEIGHBOUR' => IMG_NEAREST_NEIGHBOUR,
30    'IMG_WEIGHTED4' => IMG_WEIGHTED4,
31    'IMG_TRIANGLE' => IMG_TRIANGLE,
32);
33
34$img = imagecreate(40, 20);
35$results = array();
36
37foreach ($interpolations as $name => $interpolation) {
38  imagesetinterpolation($img, $interpolation);
39  $t = imagecolorallocatealpha($img, 0, 0, 0, 127);
40  $imgr = imagerotate($img, -5, $t);
41  $results[$name] = array('x' => imagesx($imgr), 'y' => imagesy($imgr));
42  imagedestroy($imgr);
43}
44
45imagedestroy($img);
46print_r($results);
47?>
48--EXPECT--
49Array
50(
51    [IMG_BELL] => Array
52        (
53            [x] => 40
54            [y] => 23
55        )
56
57    [IMG_BESSEL] => Array
58        (
59            [x] => 40
60            [y] => 23
61        )
62
63    [IMG_BICUBIC] => Array
64        (
65            [x] => 40
66            [y] => 23
67        )
68
69    [IMG_BICUBIC_FIXED] => Array
70        (
71            [x] => 40
72            [y] => 23
73        )
74
75    [IMG_BILINEAR_FIXED] => Array
76        (
77            [x] => 40
78            [y] => 23
79        )
80
81    [IMG_BLACKMAN] => Array
82        (
83            [x] => 40
84            [y] => 23
85        )
86
87    [IMG_BOX] => Array
88        (
89            [x] => 40
90            [y] => 23
91        )
92
93    [IMG_BSPLINE] => Array
94        (
95            [x] => 40
96            [y] => 23
97        )
98
99    [IMG_CATMULLROM] => Array
100        (
101            [x] => 40
102            [y] => 23
103        )
104
105    [IMG_GAUSSIAN] => Array
106        (
107            [x] => 40
108            [y] => 23
109        )
110
111    [IMG_GENERALIZED_CUBIC] => Array
112        (
113            [x] => 40
114            [y] => 23
115        )
116
117    [IMG_HERMITE] => Array
118        (
119            [x] => 40
120            [y] => 23
121        )
122
123    [IMG_HAMMING] => Array
124        (
125            [x] => 40
126            [y] => 23
127        )
128
129    [IMG_HANNING] => Array
130        (
131            [x] => 40
132            [y] => 23
133        )
134
135    [IMG_MITCHELL] => Array
136        (
137            [x] => 40
138            [y] => 23
139        )
140
141    [IMG_POWER] => Array
142        (
143            [x] => 40
144            [y] => 23
145        )
146
147    [IMG_QUADRATIC] => Array
148        (
149            [x] => 40
150            [y] => 23
151        )
152
153    [IMG_SINC] => Array
154        (
155            [x] => 40
156            [y] => 23
157        )
158
159    [IMG_NEAREST_NEIGHBOUR] => Array
160        (
161            [x] => 40
162            [y] => 23
163        )
164
165    [IMG_WEIGHTED4] => Array
166        (
167            [x] => 40
168            [y] => 23
169        )
170
171    [IMG_TRIANGLE] => Array
172        (
173            [x] => 40
174            [y] => 23
175        )
176
177)
178