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