xref: /PHP-7.2/ext/gd/tests/bug65148.phpt (revision 22c48761)
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===DONE===
49--EXPECT--
50Array
51(
52    [IMG_BELL] => Array
53        (
54            [x] => 40
55            [y] => 23
56        )
57
58    [IMG_BESSEL] => Array
59        (
60            [x] => 40
61            [y] => 23
62        )
63
64    [IMG_BICUBIC] => Array
65        (
66            [x] => 40
67            [y] => 23
68        )
69
70    [IMG_BICUBIC_FIXED] => Array
71        (
72            [x] => 40
73            [y] => 23
74        )
75
76    [IMG_BILINEAR_FIXED] => Array
77        (
78            [x] => 40
79            [y] => 23
80        )
81
82    [IMG_BLACKMAN] => Array
83        (
84            [x] => 40
85            [y] => 23
86        )
87
88    [IMG_BOX] => Array
89        (
90            [x] => 40
91            [y] => 23
92        )
93
94    [IMG_BSPLINE] => Array
95        (
96            [x] => 40
97            [y] => 23
98        )
99
100    [IMG_CATMULLROM] => Array
101        (
102            [x] => 40
103            [y] => 23
104        )
105
106    [IMG_GAUSSIAN] => Array
107        (
108            [x] => 40
109            [y] => 23
110        )
111
112    [IMG_GENERALIZED_CUBIC] => Array
113        (
114            [x] => 40
115            [y] => 23
116        )
117
118    [IMG_HERMITE] => Array
119        (
120            [x] => 40
121            [y] => 23
122        )
123
124    [IMG_HAMMING] => Array
125        (
126            [x] => 40
127            [y] => 23
128        )
129
130    [IMG_HANNING] => Array
131        (
132            [x] => 40
133            [y] => 23
134        )
135
136    [IMG_MITCHELL] => Array
137        (
138            [x] => 40
139            [y] => 23
140        )
141
142    [IMG_POWER] => Array
143        (
144            [x] => 40
145            [y] => 23
146        )
147
148    [IMG_QUADRATIC] => Array
149        (
150            [x] => 40
151            [y] => 23
152        )
153
154    [IMG_SINC] => Array
155        (
156            [x] => 40
157            [y] => 23
158        )
159
160    [IMG_NEAREST_NEIGHBOUR] => Array
161        (
162            [x] => 40
163            [y] => 23
164        )
165
166    [IMG_WEIGHTED4] => Array
167        (
168            [x] => 40
169            [y] => 23
170        )
171
172    [IMG_TRIANGLE] => Array
173        (
174            [x] => 40
175            [y] => 23
176        )
177
178)
179===DONE===
180