1
2 #ifdef HAVE_CONFIG_H
3 #include "../../../ext_config.h"
4 #endif
5
6 #include <php.h>
7 #include "../../../php_ext.h"
8 #include "../../../ext.h"
9
10 #include <Zend/zend_operators.h>
11 #include <Zend/zend_exceptions.h>
12 #include <Zend/zend_interfaces.h>
13
14 #include "kernel/main.h"
15 #include "kernel/object.h"
16 #include "kernel/operators.h"
17 #include "kernel/exception.h"
18 #include "kernel/memory.h"
19 #include "kernel/fcall.h"
20 #include "kernel/string.h"
21 #include "kernel/array.h"
22 #include "kernel/concat.h"
23 #include "kernel/file.h"
24 #include "ext/spl/spl_exceptions.h"
25 #include "kernel/math.h"
26
27
ZEPHIR_INIT_CLASS(Phalcon_Image_Adapter_Gd)28 ZEPHIR_INIT_CLASS(Phalcon_Image_Adapter_Gd) {
29
30 ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Image\\Adapter, Gd, phalcon, image_adapter_gd, phalcon_image_adapter_ce, phalcon_image_adapter_gd_method_entry, 0);
31
32 zend_declare_property_bool(phalcon_image_adapter_gd_ce, SL("_checked"), 0, ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC);
33
34 return SUCCESS;
35
36 }
37
PHP_METHOD(Phalcon_Image_Adapter_Gd,check)38 PHP_METHOD(Phalcon_Image_Adapter_Gd, check) {
39
40 zval *version = NULL, *info = NULL, *matches = NULL, *_0, _1 = zval_used_for_init, *_2 = NULL, _6, *_7 = NULL, *_10, *_3$$6, *_4$$6, _5$$6, *_8$$8, *_9$$8;
41 zend_long ZEPHIR_LAST_CALL_STATUS;
42
43 ZEPHIR_MM_GROW();
44
45 _0 = zephir_fetch_static_property_ce(phalcon_image_adapter_gd_ce, SL("_checked") TSRMLS_CC);
46 if (zephir_is_true(_0)) {
47 RETURN_MM_BOOL(1);
48 }
49 if (!((zephir_function_exists_ex(SS("gd_info") TSRMLS_CC) == SUCCESS))) {
50 ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "GD is either not installed or not enabled, check your configuration", "phalcon/image/adapter/gd.zep", 38);
51 return;
52 }
53 ZEPHIR_INIT_VAR(version);
54 ZVAL_NULL(version);
55 ZEPHIR_SINIT_VAR(_1);
56 ZVAL_STRING(&_1, "GD_VERSION", 0);
57 ZEPHIR_CALL_FUNCTION(&_2, "defined", NULL, 37, &_1);
58 zephir_check_call_status();
59 if (zephir_is_true(_2)) {
60 ZEPHIR_INIT_NVAR(version);
61 ZEPHIR_GET_CONSTANT(version, "GD_VERSION");
62 } else {
63 ZEPHIR_CALL_FUNCTION(&info, "gd_info", NULL, 264);
64 zephir_check_call_status();
65 ZEPHIR_INIT_VAR(matches);
66 ZVAL_NULL(matches);
67 ZEPHIR_INIT_VAR(_3$$6);
68 zephir_array_fetch_string(&_4$$6, info, SL("GD Version"), PH_NOISY | PH_READONLY, "phalcon/image/adapter/gd.zep", 46 TSRMLS_CC);
69 ZEPHIR_SINIT_VAR(_5$$6);
70 ZVAL_STRING(&_5$$6, "/\\d+\\.\\d+(?:\\.\\d+)?/", 0);
71 zephir_preg_match(_3$$6, &_5$$6, _4$$6, matches, 0, 0 , 0 TSRMLS_CC);
72 if (zephir_is_true(_3$$6)) {
73 ZEPHIR_OBS_NVAR(version);
74 zephir_array_fetch_long(&version, matches, 0, PH_NOISY, "phalcon/image/adapter/gd.zep", 47 TSRMLS_CC);
75 }
76 }
77 ZEPHIR_SINIT_NVAR(_1);
78 ZVAL_STRING(&_1, "2.0.1", 0);
79 ZEPHIR_SINIT_VAR(_6);
80 ZVAL_STRING(&_6, ">=", 0);
81 ZEPHIR_CALL_FUNCTION(&_7, "version_compare", NULL, 265, version, &_1, &_6);
82 zephir_check_call_status();
83 if (!(zephir_is_true(_7))) {
84 ZEPHIR_INIT_VAR(_8$$8);
85 object_init_ex(_8$$8, phalcon_image_exception_ce);
86 ZEPHIR_INIT_VAR(_9$$8);
87 ZEPHIR_CONCAT_SV(_9$$8, "Phalcon\\Image\\Adapter\\GD requires GD version '2.0.1' or greater, you have ", version);
88 ZEPHIR_CALL_METHOD(NULL, _8$$8, "__construct", NULL, 9, _9$$8);
89 zephir_check_call_status();
90 zephir_throw_exception_debug(_8$$8, "phalcon/image/adapter/gd.zep", 52 TSRMLS_CC);
91 ZEPHIR_MM_RESTORE();
92 return;
93 }
94 zephir_update_static_property_ce(phalcon_image_adapter_gd_ce, SL("_checked"), &ZEPHIR_GLOBAL(global_true) TSRMLS_CC);
95 _10 = zephir_fetch_static_property_ce(phalcon_image_adapter_gd_ce, SL("_checked") TSRMLS_CC);
96 RETURN_CTOR(_10);
97
98 }
99
PHP_METHOD(Phalcon_Image_Adapter_Gd,__construct)100 PHP_METHOD(Phalcon_Image_Adapter_Gd, __construct) {
101
102 zend_bool _25$$14;
103 zend_long width, height, ZEPHIR_LAST_CALL_STATUS;
104 zval *file_param = NULL, *width_param = NULL, *height_param = NULL, *imageinfo = NULL, *_0, *_1, *_2$$4, *_3$$4 = NULL, *_4$$4, *_9$$4, *_24$$4, *_5$$5, *_6$$5, *_7$$5, *_8$$5, *_10$$6, *_11$$6 = NULL, *_12$$7, *_13$$7 = NULL, *_14$$8, *_15$$8 = NULL, *_16$$9, *_17$$9 = NULL, *_18$$10, *_19$$10 = NULL, *_20$$11, *_21$$12, *_22$$12, *_23$$12, _29$$14, _30$$14, *_31$$14 = NULL, *_32$$14, *_33$$14, *_34$$14, *_35$$14, *_26$$15, *_27$$15, *_28$$15;
105 zval *file = NULL;
106
107 ZEPHIR_MM_GROW();
108 zephir_fetch_params(1, 1, 2, &file_param, &width_param, &height_param);
109
110 if (UNEXPECTED(Z_TYPE_P(file_param) != IS_STRING && Z_TYPE_P(file_param) != IS_NULL)) {
111 zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'file' must be a string") TSRMLS_CC);
112 RETURN_MM_NULL();
113 }
114 if (EXPECTED(Z_TYPE_P(file_param) == IS_STRING)) {
115 zephir_get_strval(file, file_param);
116 } else {
117 ZEPHIR_INIT_VAR(file);
118 ZVAL_EMPTY_STRING(file);
119 }
120 if (!width_param) {
121 width = 0;
122 } else {
123 width = zephir_get_intval(width_param);
124 }
125 if (!height_param) {
126 height = 0;
127 } else {
128 height = zephir_get_intval(height_param);
129 }
130
131
132 _0 = zephir_fetch_static_property_ce(phalcon_image_adapter_gd_ce, SL("_checked") TSRMLS_CC);
133 if (!(zephir_is_true(_0))) {
134 ZEPHIR_CALL_SELF(NULL, "check", NULL, 0);
135 zephir_check_call_status();
136 }
137 zephir_update_property_this(getThis(), SL("_file"), file TSRMLS_CC);
138 _1 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC);
139 if ((zephir_file_exists(_1 TSRMLS_CC) == SUCCESS)) {
140 _2$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC);
141 ZEPHIR_CALL_FUNCTION(&_3$$4, "realpath", NULL, 67, _2$$4);
142 zephir_check_call_status();
143 zephir_update_property_this(getThis(), SL("_realpath"), _3$$4 TSRMLS_CC);
144 _4$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC);
145 ZEPHIR_CALL_FUNCTION(&imageinfo, "getimagesize", NULL, 266, _4$$4);
146 zephir_check_call_status();
147 if (zephir_is_true(imageinfo)) {
148 zephir_array_fetch_long(&_5$$5, imageinfo, 0, PH_NOISY | PH_READONLY, "phalcon/image/adapter/gd.zep", 76 TSRMLS_CC);
149 zephir_update_property_this(getThis(), SL("_width"), _5$$5 TSRMLS_CC);
150 zephir_array_fetch_long(&_6$$5, imageinfo, 1, PH_NOISY | PH_READONLY, "phalcon/image/adapter/gd.zep", 77 TSRMLS_CC);
151 zephir_update_property_this(getThis(), SL("_height"), _6$$5 TSRMLS_CC);
152 zephir_array_fetch_long(&_7$$5, imageinfo, 2, PH_NOISY | PH_READONLY, "phalcon/image/adapter/gd.zep", 78 TSRMLS_CC);
153 zephir_update_property_this(getThis(), SL("_type"), _7$$5 TSRMLS_CC);
154 zephir_array_fetch_string(&_8$$5, imageinfo, SL("mime"), PH_NOISY | PH_READONLY, "phalcon/image/adapter/gd.zep", 79 TSRMLS_CC);
155 zephir_update_property_this(getThis(), SL("_mime"), _8$$5 TSRMLS_CC);
156 }
157 _9$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC);
158 do {
159 if (ZEPHIR_IS_LONG(_9$$4, 1)) {
160 _10$$6 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC);
161 ZEPHIR_CALL_FUNCTION(&_11$$6, "imagecreatefromgif", NULL, 267, _10$$6);
162 zephir_check_call_status();
163 zephir_update_property_this(getThis(), SL("_image"), _11$$6 TSRMLS_CC);
164 break;
165 }
166 if (ZEPHIR_IS_LONG(_9$$4, 2)) {
167 _12$$7 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC);
168 ZEPHIR_CALL_FUNCTION(&_13$$7, "imagecreatefromjpeg", NULL, 268, _12$$7);
169 zephir_check_call_status();
170 zephir_update_property_this(getThis(), SL("_image"), _13$$7 TSRMLS_CC);
171 break;
172 }
173 if (ZEPHIR_IS_LONG(_9$$4, 3)) {
174 _14$$8 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC);
175 ZEPHIR_CALL_FUNCTION(&_15$$8, "imagecreatefrompng", NULL, 269, _14$$8);
176 zephir_check_call_status();
177 zephir_update_property_this(getThis(), SL("_image"), _15$$8 TSRMLS_CC);
178 break;
179 }
180 if (ZEPHIR_IS_LONG(_9$$4, 15)) {
181 _16$$9 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC);
182 ZEPHIR_CALL_FUNCTION(&_17$$9, "imagecreatefromwbmp", NULL, 270, _16$$9);
183 zephir_check_call_status();
184 zephir_update_property_this(getThis(), SL("_image"), _17$$9 TSRMLS_CC);
185 break;
186 }
187 if (ZEPHIR_IS_LONG(_9$$4, 16)) {
188 _18$$10 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC);
189 ZEPHIR_CALL_FUNCTION(&_19$$10, "imagecreatefromxbm", NULL, 271, _18$$10);
190 zephir_check_call_status();
191 zephir_update_property_this(getThis(), SL("_image"), _19$$10 TSRMLS_CC);
192 break;
193 }
194 _20$$11 = zephir_fetch_nproperty_this(this_ptr, SL("_mime"), PH_NOISY_CC);
195 if (zephir_is_true(_20$$11)) {
196 ZEPHIR_INIT_VAR(_21$$12);
197 object_init_ex(_21$$12, phalcon_image_exception_ce);
198 _22$$12 = zephir_fetch_nproperty_this(this_ptr, SL("_mime"), PH_NOISY_CC);
199 ZEPHIR_INIT_VAR(_23$$12);
200 ZEPHIR_CONCAT_SVS(_23$$12, "Installed GD does not support ", _22$$12, " images");
201 ZEPHIR_CALL_METHOD(NULL, _21$$12, "__construct", NULL, 9, _23$$12);
202 zephir_check_call_status();
203 zephir_throw_exception_debug(_21$$12, "phalcon/image/adapter/gd.zep", 100 TSRMLS_CC);
204 ZEPHIR_MM_RESTORE();
205 return;
206 } else {
207 ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Installed GD does not support such images", "phalcon/image/adapter/gd.zep", 102);
208 return;
209 }
210 break;
211 } while(0);
212
213 _24$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
214 ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 272, _24$$4, ZEPHIR_GLOBAL(global_true));
215 zephir_check_call_status();
216 } else {
217 _25$$14 = !width;
218 if (!(_25$$14)) {
219 _25$$14 = !height;
220 }
221 if (_25$$14) {
222 ZEPHIR_INIT_VAR(_26$$15);
223 object_init_ex(_26$$15, phalcon_image_exception_ce);
224 _27$$15 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC);
225 ZEPHIR_INIT_VAR(_28$$15);
226 ZEPHIR_CONCAT_SV(_28$$15, "Failed to create image from file ", _27$$15);
227 ZEPHIR_CALL_METHOD(NULL, _26$$15, "__construct", NULL, 9, _28$$15);
228 zephir_check_call_status();
229 zephir_throw_exception_debug(_26$$15, "phalcon/image/adapter/gd.zep", 111 TSRMLS_CC);
230 ZEPHIR_MM_RESTORE();
231 return;
232 }
233 ZEPHIR_SINIT_VAR(_29$$14);
234 ZVAL_LONG(&_29$$14, width);
235 ZEPHIR_SINIT_VAR(_30$$14);
236 ZVAL_LONG(&_30$$14, height);
237 ZEPHIR_CALL_FUNCTION(&_31$$14, "imagecreatetruecolor", NULL, 273, &_29$$14, &_30$$14);
238 zephir_check_call_status();
239 zephir_update_property_this(getThis(), SL("_image"), _31$$14 TSRMLS_CC);
240 _32$$14 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
241 ZEPHIR_CALL_FUNCTION(NULL, "imagealphablending", NULL, 274, _32$$14, ZEPHIR_GLOBAL(global_true));
242 zephir_check_call_status();
243 _33$$14 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
244 ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 272, _33$$14, ZEPHIR_GLOBAL(global_true));
245 zephir_check_call_status();
246 _34$$14 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC);
247 zephir_update_property_this(getThis(), SL("_realpath"), _34$$14 TSRMLS_CC);
248 ZEPHIR_INIT_ZVAL_NREF(_35$$14);
249 ZVAL_LONG(_35$$14, width);
250 zephir_update_property_this(getThis(), SL("_width"), _35$$14 TSRMLS_CC);
251 ZEPHIR_INIT_ZVAL_NREF(_35$$14);
252 ZVAL_LONG(_35$$14, height);
253 zephir_update_property_this(getThis(), SL("_height"), _35$$14 TSRMLS_CC);
254 ZEPHIR_INIT_ZVAL_NREF(_35$$14);
255 ZVAL_LONG(_35$$14, 3);
256 zephir_update_property_this(getThis(), SL("_type"), _35$$14 TSRMLS_CC);
257 ZEPHIR_INIT_ZVAL_NREF(_35$$14);
258 ZVAL_STRING(_35$$14, "image/png", 1);
259 zephir_update_property_this(getThis(), SL("_mime"), _35$$14 TSRMLS_CC);
260 }
261 ZEPHIR_MM_RESTORE();
262
263 }
264
PHP_METHOD(Phalcon_Image_Adapter_Gd,_resize)265 PHP_METHOD(Phalcon_Image_Adapter_Gd, _resize) {
266
267 zend_bool _4$$3, _8$$4;
268 zval *width_param = NULL, *height_param = NULL, *image = NULL, *pre_width = NULL, *pre_height = NULL, *reduction_width = NULL, *reduction_height = NULL, *_0, _1, *_2 = NULL, *_3$$3, *_5$$3, *_18$$3, *_19$$3, *_20$$3, _21$$3, _22$$3, _23$$3, _24$$3, _25$$3, _26$$3, *_27$$3 = NULL, _6$$4, _7$$4, *_9$$4, *_10$$4, *_11$$4, _12$$4, _13$$4, _14$$4, _15$$4, *_16$$4 = NULL, *_17$$6, *_28$$7, *_29$$7 = NULL, *_30$$7 = NULL, *_31$$8, _32$$8, _33$$8, *_34$$8, *_35$$8 = NULL, *_36$$8 = NULL;
269 zend_long width, height, ZEPHIR_LAST_CALL_STATUS;
270
271 ZEPHIR_MM_GROW();
272 zephir_fetch_params(1, 2, 0, &width_param, &height_param);
273
274 width = zephir_get_intval(width_param);
275 height = zephir_get_intval(height_param);
276
277
278 ZEPHIR_INIT_VAR(_0);
279 ZEPHIR_GET_CONSTANT(_0, "PHP_VERSION");
280 ZEPHIR_SINIT_VAR(_1);
281 ZVAL_STRING(&_1, "5.5.0", 0);
282 ZEPHIR_CALL_FUNCTION(&_2, "version_compare", NULL, 265, _0, &_1);
283 zephir_check_call_status();
284 if (ZEPHIR_LT_LONG(_2, 0)) {
285 ZEPHIR_OBS_VAR(pre_width);
286 zephir_read_property_this(&pre_width, this_ptr, SL("_width"), PH_NOISY_CC);
287 ZEPHIR_OBS_VAR(pre_height);
288 zephir_read_property_this(&pre_height, this_ptr, SL("_height"), PH_NOISY_CC);
289 _3$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
290 _4$$3 = width > (zephir_safe_div_zval_long(_3$$3, 2 TSRMLS_CC));
291 if (_4$$3) {
292 _5$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
293 _4$$3 = height > (zephir_safe_div_zval_long(_5$$3, 2 TSRMLS_CC));
294 }
295 if (_4$$3) {
296 ZEPHIR_SINIT_VAR(_6$$4);
297 ZVAL_LONG(&_6$$4, (width * 1.1));
298 ZEPHIR_INIT_VAR(reduction_width);
299 zephir_round(reduction_width, &_6$$4, NULL, NULL TSRMLS_CC);
300 ZEPHIR_SINIT_VAR(_7$$4);
301 ZVAL_LONG(&_7$$4, (height * 1.1));
302 ZEPHIR_INIT_VAR(reduction_height);
303 zephir_round(reduction_height, &_7$$4, NULL, NULL TSRMLS_CC);
304 while (1) {
305 _8$$4 = ZEPHIR_LT_LONG(reduction_width, zephir_safe_div_zval_long(pre_width, 2 TSRMLS_CC));
306 if (_8$$4) {
307 _8$$4 = ZEPHIR_LT_LONG(reduction_height, zephir_safe_div_zval_long(pre_height, 2 TSRMLS_CC));
308 }
309 if (!(_8$$4)) {
310 break;
311 }
312 ZEPHIR_INIT_NVAR(pre_width);
313 ZVAL_DOUBLE(pre_width, 2);
314 ZEPHIR_INIT_NVAR(pre_height);
315 ZVAL_DOUBLE(pre_height, 2);
316 }
317 ZEPHIR_CALL_METHOD(&image, this_ptr, "_create", NULL, 0, pre_width, pre_height);
318 zephir_check_call_status();
319 _9$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
320 _10$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
321 _11$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
322 ZEPHIR_SINIT_VAR(_12$$4);
323 ZVAL_LONG(&_12$$4, 0);
324 ZEPHIR_SINIT_VAR(_13$$4);
325 ZVAL_LONG(&_13$$4, 0);
326 ZEPHIR_SINIT_VAR(_14$$4);
327 ZVAL_LONG(&_14$$4, 0);
328 ZEPHIR_SINIT_VAR(_15$$4);
329 ZVAL_LONG(&_15$$4, 0);
330 ZEPHIR_CALL_FUNCTION(&_16$$4, "imagecopyresized", NULL, 275, image, _9$$4, &_12$$4, &_13$$4, &_14$$4, &_15$$4, pre_width, pre_height, _10$$4, _11$$4);
331 zephir_check_call_status();
332 if (zephir_is_true(_16$$4)) {
333 _17$$6 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
334 ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 276, _17$$6);
335 zephir_check_call_status();
336 zephir_update_property_this(getThis(), SL("_image"), image TSRMLS_CC);
337 }
338 }
339 ZEPHIR_INIT_VAR(_18$$3);
340 ZVAL_LONG(_18$$3, width);
341 ZEPHIR_INIT_VAR(_19$$3);
342 ZVAL_LONG(_19$$3, height);
343 ZEPHIR_CALL_METHOD(&image, this_ptr, "_create", NULL, 0, _18$$3, _19$$3);
344 zephir_check_call_status();
345 _20$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
346 ZEPHIR_SINIT_VAR(_21$$3);
347 ZVAL_LONG(&_21$$3, 0);
348 ZEPHIR_SINIT_VAR(_22$$3);
349 ZVAL_LONG(&_22$$3, 0);
350 ZEPHIR_SINIT_VAR(_23$$3);
351 ZVAL_LONG(&_23$$3, 0);
352 ZEPHIR_SINIT_VAR(_24$$3);
353 ZVAL_LONG(&_24$$3, 0);
354 ZEPHIR_SINIT_VAR(_25$$3);
355 ZVAL_LONG(&_25$$3, width);
356 ZEPHIR_SINIT_VAR(_26$$3);
357 ZVAL_LONG(&_26$$3, height);
358 ZEPHIR_CALL_FUNCTION(&_27$$3, "imagecopyresampled", NULL, 277, image, _20$$3, &_21$$3, &_22$$3, &_23$$3, &_24$$3, &_25$$3, &_26$$3, pre_width, pre_height);
359 zephir_check_call_status();
360 if (zephir_is_true(_27$$3)) {
361 _28$$7 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
362 ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 276, _28$$7);
363 zephir_check_call_status();
364 zephir_update_property_this(getThis(), SL("_image"), image TSRMLS_CC);
365 ZEPHIR_CALL_FUNCTION(&_29$$7, "imagesx", NULL, 278, image);
366 zephir_check_call_status();
367 zephir_update_property_this(getThis(), SL("_width"), _29$$7 TSRMLS_CC);
368 ZEPHIR_CALL_FUNCTION(&_30$$7, "imagesy", NULL, 279, image);
369 zephir_check_call_status();
370 zephir_update_property_this(getThis(), SL("_height"), _30$$7 TSRMLS_CC);
371 }
372 } else {
373 _31$$8 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
374 ZEPHIR_SINIT_VAR(_32$$8);
375 ZVAL_LONG(&_32$$8, width);
376 ZEPHIR_SINIT_VAR(_33$$8);
377 ZVAL_LONG(&_33$$8, height);
378 ZEPHIR_CALL_FUNCTION(&image, "imagescale", NULL, 280, _31$$8, &_32$$8, &_33$$8);
379 zephir_check_call_status();
380 _34$$8 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
381 ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 276, _34$$8);
382 zephir_check_call_status();
383 zephir_update_property_this(getThis(), SL("_image"), image TSRMLS_CC);
384 ZEPHIR_CALL_FUNCTION(&_35$$8, "imagesx", NULL, 278, image);
385 zephir_check_call_status();
386 zephir_update_property_this(getThis(), SL("_width"), _35$$8 TSRMLS_CC);
387 ZEPHIR_CALL_FUNCTION(&_36$$8, "imagesy", NULL, 279, image);
388 zephir_check_call_status();
389 zephir_update_property_this(getThis(), SL("_height"), _36$$8 TSRMLS_CC);
390 }
391 ZEPHIR_MM_RESTORE();
392
393 }
394
PHP_METHOD(Phalcon_Image_Adapter_Gd,_crop)395 PHP_METHOD(Phalcon_Image_Adapter_Gd, _crop) {
396
397 zval *width_param = NULL, *height_param = NULL, *offsetX_param = NULL, *offsetY_param = NULL, *image = NULL, *rect = NULL, *_0, _1, *_2 = NULL, *_3$$3, *_4$$3, *_5$$3, _6$$3, _7$$3, _8$$3, _9$$3, _10$$3, _11$$3, _12$$3, _13$$3, *_14$$3 = NULL, *_15$$4, *_16$$4 = NULL, *_17$$4 = NULL, *_18$$5 = NULL, *_19$$5, *_20$$5, *_21$$5 = NULL, *_22$$5 = NULL;
398 zend_long width, height, offsetX, offsetY, ZEPHIR_LAST_CALL_STATUS;
399
400 ZEPHIR_MM_GROW();
401 zephir_fetch_params(1, 4, 0, &width_param, &height_param, &offsetX_param, &offsetY_param);
402
403 width = zephir_get_intval(width_param);
404 height = zephir_get_intval(height_param);
405 offsetX = zephir_get_intval(offsetX_param);
406 offsetY = zephir_get_intval(offsetY_param);
407
408
409 ZEPHIR_INIT_VAR(_0);
410 ZEPHIR_GET_CONSTANT(_0, "PHP_VERSION");
411 ZEPHIR_SINIT_VAR(_1);
412 ZVAL_STRING(&_1, "5.5.0", 0);
413 ZEPHIR_CALL_FUNCTION(&_2, "version_compare", NULL, 265, _0, &_1);
414 zephir_check_call_status();
415 if (ZEPHIR_LT_LONG(_2, 0)) {
416 ZEPHIR_INIT_VAR(_3$$3);
417 ZVAL_LONG(_3$$3, width);
418 ZEPHIR_INIT_VAR(_4$$3);
419 ZVAL_LONG(_4$$3, height);
420 ZEPHIR_CALL_METHOD(&image, this_ptr, "_create", NULL, 0, _3$$3, _4$$3);
421 zephir_check_call_status();
422 _5$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
423 ZEPHIR_SINIT_VAR(_6$$3);
424 ZVAL_LONG(&_6$$3, 0);
425 ZEPHIR_SINIT_VAR(_7$$3);
426 ZVAL_LONG(&_7$$3, 0);
427 ZEPHIR_SINIT_VAR(_8$$3);
428 ZVAL_LONG(&_8$$3, offsetX);
429 ZEPHIR_SINIT_VAR(_9$$3);
430 ZVAL_LONG(&_9$$3, offsetY);
431 ZEPHIR_SINIT_VAR(_10$$3);
432 ZVAL_LONG(&_10$$3, width);
433 ZEPHIR_SINIT_VAR(_11$$3);
434 ZVAL_LONG(&_11$$3, height);
435 ZEPHIR_SINIT_VAR(_12$$3);
436 ZVAL_LONG(&_12$$3, width);
437 ZEPHIR_SINIT_VAR(_13$$3);
438 ZVAL_LONG(&_13$$3, height);
439 ZEPHIR_CALL_FUNCTION(&_14$$3, "imagecopyresampled", NULL, 277, image, _5$$3, &_6$$3, &_7$$3, &_8$$3, &_9$$3, &_10$$3, &_11$$3, &_12$$3, &_13$$3);
440 zephir_check_call_status();
441 if (zephir_is_true(_14$$3)) {
442 _15$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
443 ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 276, _15$$4);
444 zephir_check_call_status();
445 zephir_update_property_this(getThis(), SL("_image"), image TSRMLS_CC);
446 ZEPHIR_CALL_FUNCTION(&_16$$4, "imagesx", NULL, 278, image);
447 zephir_check_call_status();
448 zephir_update_property_this(getThis(), SL("_width"), _16$$4 TSRMLS_CC);
449 ZEPHIR_CALL_FUNCTION(&_17$$4, "imagesy", NULL, 279, image);
450 zephir_check_call_status();
451 zephir_update_property_this(getThis(), SL("_height"), _17$$4 TSRMLS_CC);
452 }
453 } else {
454 ZEPHIR_INIT_VAR(rect);
455 zephir_create_array(rect, 4, 0 TSRMLS_CC);
456 ZEPHIR_INIT_VAR(_18$$5);
457 ZVAL_LONG(_18$$5, offsetX);
458 zephir_array_update_string(&rect, SL("x"), &_18$$5, PH_COPY | PH_SEPARATE);
459 ZEPHIR_INIT_NVAR(_18$$5);
460 ZVAL_LONG(_18$$5, offsetY);
461 zephir_array_update_string(&rect, SL("y"), &_18$$5, PH_COPY | PH_SEPARATE);
462 ZEPHIR_INIT_NVAR(_18$$5);
463 ZVAL_LONG(_18$$5, width);
464 zephir_array_update_string(&rect, SL("width"), &_18$$5, PH_COPY | PH_SEPARATE);
465 ZEPHIR_INIT_NVAR(_18$$5);
466 ZVAL_LONG(_18$$5, height);
467 zephir_array_update_string(&rect, SL("height"), &_18$$5, PH_COPY | PH_SEPARATE);
468 _19$$5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
469 ZEPHIR_CALL_FUNCTION(&image, "imagecrop", NULL, 281, _19$$5, rect);
470 zephir_check_call_status();
471 _20$$5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
472 ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 276, _20$$5);
473 zephir_check_call_status();
474 zephir_update_property_this(getThis(), SL("_image"), image TSRMLS_CC);
475 ZEPHIR_CALL_FUNCTION(&_21$$5, "imagesx", NULL, 278, image);
476 zephir_check_call_status();
477 zephir_update_property_this(getThis(), SL("_width"), _21$$5 TSRMLS_CC);
478 ZEPHIR_CALL_FUNCTION(&_22$$5, "imagesy", NULL, 279, image);
479 zephir_check_call_status();
480 zephir_update_property_this(getThis(), SL("_height"), _22$$5 TSRMLS_CC);
481 }
482 ZEPHIR_MM_RESTORE();
483
484 }
485
PHP_METHOD(Phalcon_Image_Adapter_Gd,_rotate)486 PHP_METHOD(Phalcon_Image_Adapter_Gd, _rotate) {
487
488 zval *degrees_param = NULL, *image = NULL, *transparent = NULL, *width = NULL, *height = NULL, *_0, _1 = zval_used_for_init, _2 = zval_used_for_init, _3 = zval_used_for_init, _4 = zval_used_for_init, *_5, *_6, _7, *_8 = NULL, *_9$$3;
489 zend_long degrees, ZEPHIR_LAST_CALL_STATUS;
490
491 ZEPHIR_MM_GROW();
492 zephir_fetch_params(1, 1, 0, °rees_param);
493
494 degrees = zephir_get_intval(degrees_param);
495
496
497 _0 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
498 ZEPHIR_SINIT_VAR(_1);
499 ZVAL_LONG(&_1, 0);
500 ZEPHIR_SINIT_VAR(_2);
501 ZVAL_LONG(&_2, 0);
502 ZEPHIR_SINIT_VAR(_3);
503 ZVAL_LONG(&_3, 0);
504 ZEPHIR_SINIT_VAR(_4);
505 ZVAL_LONG(&_4, 127);
506 ZEPHIR_CALL_FUNCTION(&transparent, "imagecolorallocatealpha", NULL, 282, _0, &_1, &_2, &_3, &_4);
507 zephir_check_call_status();
508 _5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
509 ZEPHIR_SINIT_NVAR(_1);
510 ZVAL_LONG(&_1, (360 - degrees));
511 ZEPHIR_SINIT_NVAR(_2);
512 ZVAL_LONG(&_2, 1);
513 ZEPHIR_CALL_FUNCTION(&image, "imagerotate", NULL, 283, _5, &_1, transparent, &_2);
514 zephir_check_call_status();
515 ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 272, image, ZEPHIR_GLOBAL(global_true));
516 zephir_check_call_status();
517 ZEPHIR_CALL_FUNCTION(&width, "imagesx", NULL, 278, image);
518 zephir_check_call_status();
519 ZEPHIR_CALL_FUNCTION(&height, "imagesy", NULL, 279, image);
520 zephir_check_call_status();
521 _6 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
522 ZEPHIR_SINIT_NVAR(_1);
523 ZVAL_LONG(&_1, 0);
524 ZEPHIR_SINIT_NVAR(_2);
525 ZVAL_LONG(&_2, 0);
526 ZEPHIR_SINIT_NVAR(_3);
527 ZVAL_LONG(&_3, 0);
528 ZEPHIR_SINIT_NVAR(_4);
529 ZVAL_LONG(&_4, 0);
530 ZEPHIR_SINIT_VAR(_7);
531 ZVAL_LONG(&_7, 100);
532 ZEPHIR_CALL_FUNCTION(&_8, "imagecopymerge", NULL, 284, _6, image, &_1, &_2, &_3, &_4, width, height, &_7);
533 zephir_check_call_status();
534 if (zephir_is_true(_8)) {
535 _9$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
536 ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 276, _9$$3);
537 zephir_check_call_status();
538 zephir_update_property_this(getThis(), SL("_image"), image TSRMLS_CC);
539 zephir_update_property_this(getThis(), SL("_width"), width TSRMLS_CC);
540 zephir_update_property_this(getThis(), SL("_height"), height TSRMLS_CC);
541 }
542 ZEPHIR_MM_RESTORE();
543
544 }
545
PHP_METHOD(Phalcon_Image_Adapter_Gd,_flip)546 PHP_METHOD(Phalcon_Image_Adapter_Gd, _flip) {
547
548 zephir_fcall_cache_entry *_14 = NULL;
549 zval *direction_param = NULL, *image = NULL, *_0, _1, *_2 = NULL, *_3$$3, *_4$$3, *_24$$3, *_25$$3 = NULL, *_26$$3 = NULL, *_5$$4, *_6$$5, *_7$$5, *_8$$5, _9$$5 = zval_used_for_init, _10$$5 = zval_used_for_init, _11$$5 = zval_used_for_init, _12$$5 = zval_used_for_init, _13$$5 = zval_used_for_init, *_15$$6, *_16$$7, *_17$$7, *_18$$7, _19$$7 = zval_used_for_init, _20$$7 = zval_used_for_init, _21$$7 = zval_used_for_init, _22$$7 = zval_used_for_init, _23$$7 = zval_used_for_init, *_27$$9, _28$$9, *_29$$10, _30$$10;
550 zend_long direction, ZEPHIR_LAST_CALL_STATUS, x = 0;
551
552 ZEPHIR_MM_GROW();
553 zephir_fetch_params(1, 1, 0, &direction_param);
554
555 direction = zephir_get_intval(direction_param);
556
557
558 ZEPHIR_INIT_VAR(_0);
559 ZEPHIR_GET_CONSTANT(_0, "PHP_VERSION");
560 ZEPHIR_SINIT_VAR(_1);
561 ZVAL_STRING(&_1, "5.5.0", 0);
562 ZEPHIR_CALL_FUNCTION(&_2, "version_compare", NULL, 265, _0, &_1);
563 zephir_check_call_status();
564 if (ZEPHIR_LT_LONG(_2, 0)) {
565 _3$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
566 _4$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
567 ZEPHIR_CALL_METHOD(&image, this_ptr, "_create", NULL, 0, _3$$3, _4$$3);
568 zephir_check_call_status();
569 if (direction == 11) {
570 x = 0;
571 while (1) {
572 _5$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
573 if (!(ZEPHIR_GT_LONG(_5$$4, x))) {
574 break;
575 }
576 x++;
577 _6$$5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
578 _7$$5 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
579 _8$$5 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
580 ZEPHIR_SINIT_NVAR(_9$$5);
581 ZVAL_LONG(&_9$$5, x);
582 ZEPHIR_SINIT_NVAR(_10$$5);
583 ZVAL_LONG(&_10$$5, 0);
584 ZEPHIR_SINIT_NVAR(_11$$5);
585 ZVAL_LONG(&_11$$5, ((zephir_get_numberval(_7$$5) - x) - 1));
586 ZEPHIR_SINIT_NVAR(_12$$5);
587 ZVAL_LONG(&_12$$5, 0);
588 ZEPHIR_SINIT_NVAR(_13$$5);
589 ZVAL_LONG(&_13$$5, 1);
590 ZEPHIR_CALL_FUNCTION(NULL, "imagecopy", &_14, 285, image, _6$$5, &_9$$5, &_10$$5, &_11$$5, &_12$$5, &_13$$5, _8$$5);
591 zephir_check_call_status();
592 }
593 } else {
594 x = 0;
595 while (1) {
596 _15$$6 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
597 if (!(ZEPHIR_GT_LONG(_15$$6, x))) {
598 break;
599 }
600 x++;
601 _16$$7 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
602 _17$$7 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
603 _18$$7 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
604 ZEPHIR_SINIT_NVAR(_19$$7);
605 ZVAL_LONG(&_19$$7, 0);
606 ZEPHIR_SINIT_NVAR(_20$$7);
607 ZVAL_LONG(&_20$$7, x);
608 ZEPHIR_SINIT_NVAR(_21$$7);
609 ZVAL_LONG(&_21$$7, 0);
610 ZEPHIR_SINIT_NVAR(_22$$7);
611 ZVAL_LONG(&_22$$7, ((zephir_get_numberval(_17$$7) - x) - 1));
612 ZEPHIR_SINIT_NVAR(_23$$7);
613 ZVAL_LONG(&_23$$7, 1);
614 ZEPHIR_CALL_FUNCTION(NULL, "imagecopy", &_14, 285, image, _16$$7, &_19$$7, &_20$$7, &_21$$7, &_22$$7, _18$$7, &_23$$7);
615 zephir_check_call_status();
616 }
617 }
618 _24$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
619 ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 276, _24$$3);
620 zephir_check_call_status();
621 zephir_update_property_this(getThis(), SL("_image"), image TSRMLS_CC);
622 ZEPHIR_CALL_FUNCTION(&_25$$3, "imagesx", NULL, 278, image);
623 zephir_check_call_status();
624 zephir_update_property_this(getThis(), SL("_width"), _25$$3 TSRMLS_CC);
625 ZEPHIR_CALL_FUNCTION(&_26$$3, "imagesy", NULL, 279, image);
626 zephir_check_call_status();
627 zephir_update_property_this(getThis(), SL("_height"), _26$$3 TSRMLS_CC);
628 } else {
629 if (direction == 11) {
630 _27$$9 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
631 ZEPHIR_SINIT_VAR(_28$$9);
632 ZVAL_LONG(&_28$$9, 1);
633 ZEPHIR_CALL_FUNCTION(NULL, "imageflip", NULL, 286, _27$$9, &_28$$9);
634 zephir_check_call_status();
635 } else {
636 _29$$10 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
637 ZEPHIR_SINIT_VAR(_30$$10);
638 ZVAL_LONG(&_30$$10, 2);
639 ZEPHIR_CALL_FUNCTION(NULL, "imageflip", NULL, 286, _29$$10, &_30$$10);
640 zephir_check_call_status();
641 }
642 }
643 ZEPHIR_MM_RESTORE();
644
645 }
646
PHP_METHOD(Phalcon_Image_Adapter_Gd,_sharpen)647 PHP_METHOD(Phalcon_Image_Adapter_Gd, _sharpen) {
648
649 zval *_3 = NULL;
650 zval *amount_param = NULL, *matrix = NULL, *_0, _1 = zval_used_for_init, *_2 = NULL, *_4 = NULL, *_5, _6, _7, *_8 = NULL, *_9$$3, *_10$$3 = NULL, *_11$$3, *_12$$3 = NULL;
651 zend_long amount, ZEPHIR_LAST_CALL_STATUS;
652
653 ZEPHIR_MM_GROW();
654 zephir_fetch_params(1, 1, 0, &amount_param);
655
656 amount = zephir_get_intval(amount_param);
657
658
659 ZEPHIR_INIT_VAR(_0);
660 ZEPHIR_SINIT_VAR(_1);
661 ZVAL_LONG(&_1, (-18 + ((amount * 0.08))));
662 ZEPHIR_CALL_FUNCTION(&_2, "abs", NULL, 213, &_1);
663 zephir_check_call_status();
664 ZEPHIR_SINIT_NVAR(_1);
665 ZVAL_LONG(&_1, 2);
666 zephir_round(_0, _2, &_1, NULL TSRMLS_CC);
667 amount = zephir_get_intval(_0);
668 ZEPHIR_INIT_VAR(matrix);
669 zephir_create_array(matrix, 3, 0 TSRMLS_CC);
670 ZEPHIR_INIT_VAR(_3);
671 zephir_create_array(_3, 3, 0 TSRMLS_CC);
672 ZEPHIR_INIT_VAR(_4);
673 ZVAL_LONG(_4, -1);
674 zephir_array_fast_append(_3, _4);
675 ZEPHIR_INIT_NVAR(_4);
676 ZVAL_LONG(_4, -1);
677 zephir_array_fast_append(_3, _4);
678 ZEPHIR_INIT_NVAR(_4);
679 ZVAL_LONG(_4, -1);
680 zephir_array_fast_append(_3, _4);
681 zephir_array_fast_append(matrix, _3);
682 ZEPHIR_INIT_NVAR(_3);
683 zephir_create_array(_3, 3, 0 TSRMLS_CC);
684 ZEPHIR_INIT_NVAR(_4);
685 ZVAL_LONG(_4, -1);
686 zephir_array_fast_append(_3, _4);
687 ZEPHIR_INIT_NVAR(_4);
688 ZVAL_LONG(_4, amount);
689 zephir_array_fast_append(_3, _4);
690 ZEPHIR_INIT_NVAR(_4);
691 ZVAL_LONG(_4, -1);
692 zephir_array_fast_append(_3, _4);
693 zephir_array_fast_append(matrix, _3);
694 ZEPHIR_INIT_NVAR(_3);
695 zephir_create_array(_3, 3, 0 TSRMLS_CC);
696 ZEPHIR_INIT_NVAR(_4);
697 ZVAL_LONG(_4, -1);
698 zephir_array_fast_append(_3, _4);
699 ZEPHIR_INIT_NVAR(_4);
700 ZVAL_LONG(_4, -1);
701 zephir_array_fast_append(_3, _4);
702 ZEPHIR_INIT_NVAR(_4);
703 ZVAL_LONG(_4, -1);
704 zephir_array_fast_append(_3, _4);
705 zephir_array_fast_append(matrix, _3);
706 _5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
707 ZEPHIR_SINIT_VAR(_6);
708 ZVAL_LONG(&_6, (amount - 8));
709 ZEPHIR_SINIT_VAR(_7);
710 ZVAL_LONG(&_7, 0);
711 ZEPHIR_CALL_FUNCTION(&_8, "imageconvolution", NULL, 287, _5, matrix, &_6, &_7);
712 zephir_check_call_status();
713 if (zephir_is_true(_8)) {
714 _9$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
715 ZEPHIR_CALL_FUNCTION(&_10$$3, "imagesx", NULL, 278, _9$$3);
716 zephir_check_call_status();
717 zephir_update_property_this(getThis(), SL("_width"), _10$$3 TSRMLS_CC);
718 _11$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
719 ZEPHIR_CALL_FUNCTION(&_12$$3, "imagesy", NULL, 279, _11$$3);
720 zephir_check_call_status();
721 zephir_update_property_this(getThis(), SL("_height"), _12$$3 TSRMLS_CC);
722 }
723 ZEPHIR_MM_RESTORE();
724
725 }
726
PHP_METHOD(Phalcon_Image_Adapter_Gd,_reflection)727 PHP_METHOD(Phalcon_Image_Adapter_Gd, _reflection) {
728
729 zephir_fcall_cache_entry *_27 = NULL;
730 zend_bool fadeIn;
731 zval *height_param = NULL, *opacity_param = NULL, *fadeIn_param = NULL, *reflection = NULL, *line = NULL, *_0, _1 = zval_used_for_init, *_2 = NULL, *_3, *_4, *_5, *_6, *_7, *_8, _9, _10, _11, *_29, *_30 = NULL, *_31 = NULL, *_12$$5, *_13$$5, *_18$$5, *_19$$5 = NULL, *_20$$5, *_21$$5, _22$$5 = zval_used_for_init, _23$$5 = zval_used_for_init, _24$$5 = zval_used_for_init, _25$$5 = zval_used_for_init, _26$$5 = zval_used_for_init, *_28$$5, *_14$$6 = NULL, _15$$6 = zval_used_for_init, *_16$$7 = NULL, _17$$7 = zval_used_for_init;
732 zend_long height, opacity, ZEPHIR_LAST_CALL_STATUS, stepping = 0, offset = 0, src_y = 0, dst_y = 0, dst_opacity = 0;
733
734 ZEPHIR_MM_GROW();
735 zephir_fetch_params(1, 3, 0, &height_param, &opacity_param, &fadeIn_param);
736
737 height = zephir_get_intval(height_param);
738 opacity = zephir_get_intval(opacity_param);
739 fadeIn = zephir_get_boolval(fadeIn_param);
740
741
742 ZEPHIR_INIT_VAR(_0);
743 ZEPHIR_SINIT_VAR(_1);
744 ZVAL_DOUBLE(&_1, ((zephir_safe_div_long_long((opacity * 127), 100 TSRMLS_CC)) - (double) (127)));
745 ZEPHIR_CALL_FUNCTION(&_2, "abs", NULL, 213, &_1);
746 zephir_check_call_status();
747 zephir_round(_0, _2, NULL, NULL TSRMLS_CC);
748 opacity = zephir_get_intval(_0);
749 if (opacity < 127) {
750 stepping = (long) (zephir_safe_div_long_long(((127 - opacity)), height TSRMLS_CC));
751 } else {
752 stepping = (long) (zephir_safe_div_long_long(127, height TSRMLS_CC));
753 }
754 _3 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
755 _4 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
756 ZEPHIR_INIT_VAR(_5);
757 ZVAL_LONG(_5, (zephir_get_numberval(_4) + height));
758 ZEPHIR_CALL_METHOD(&reflection, this_ptr, "_create", NULL, 0, _3, _5);
759 zephir_check_call_status();
760 _6 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
761 _7 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
762 _8 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
763 ZEPHIR_SINIT_NVAR(_1);
764 ZVAL_LONG(&_1, 0);
765 ZEPHIR_SINIT_VAR(_9);
766 ZVAL_LONG(&_9, 0);
767 ZEPHIR_SINIT_VAR(_10);
768 ZVAL_LONG(&_10, 0);
769 ZEPHIR_SINIT_VAR(_11);
770 ZVAL_LONG(&_11, 0);
771 ZEPHIR_CALL_FUNCTION(NULL, "imagecopy", NULL, 285, reflection, _6, &_1, &_9, &_10, &_11, _7, _8);
772 zephir_check_call_status();
773 offset = 0;
774 while (1) {
775 if (!(height >= offset)) {
776 break;
777 }
778 _12$$5 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
779 src_y = ((zephir_get_numberval(_12$$5) - offset) - 1);
780 _13$$5 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
781 dst_y = (zephir_get_numberval(_13$$5) + offset);
782 if (fadeIn) {
783 ZEPHIR_INIT_NVAR(_14$$6);
784 ZEPHIR_SINIT_NVAR(_15$$6);
785 ZVAL_LONG(&_15$$6, (opacity + ((stepping * ((height - offset))))));
786 zephir_round(_14$$6, &_15$$6, NULL, NULL TSRMLS_CC);
787 dst_opacity = zephir_get_intval(_14$$6);
788 } else {
789 ZEPHIR_INIT_NVAR(_16$$7);
790 ZEPHIR_SINIT_NVAR(_17$$7);
791 ZVAL_LONG(&_17$$7, (opacity + ((stepping * offset))));
792 zephir_round(_16$$7, &_17$$7, NULL, NULL TSRMLS_CC);
793 dst_opacity = zephir_get_intval(_16$$7);
794 }
795 _18$$5 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
796 ZEPHIR_INIT_NVAR(_19$$5);
797 ZVAL_LONG(_19$$5, 1);
798 ZEPHIR_CALL_METHOD(&line, this_ptr, "_create", NULL, 0, _18$$5, _19$$5);
799 zephir_check_call_status();
800 _20$$5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
801 _21$$5 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
802 ZEPHIR_SINIT_NVAR(_22$$5);
803 ZVAL_LONG(&_22$$5, 0);
804 ZEPHIR_SINIT_NVAR(_23$$5);
805 ZVAL_LONG(&_23$$5, 0);
806 ZEPHIR_SINIT_NVAR(_24$$5);
807 ZVAL_LONG(&_24$$5, 0);
808 ZEPHIR_SINIT_NVAR(_25$$5);
809 ZVAL_LONG(&_25$$5, src_y);
810 ZEPHIR_SINIT_NVAR(_26$$5);
811 ZVAL_LONG(&_26$$5, 1);
812 ZEPHIR_CALL_FUNCTION(NULL, "imagecopy", NULL, 285, line, _20$$5, &_22$$5, &_23$$5, &_24$$5, &_25$$5, _21$$5, &_26$$5);
813 zephir_check_call_status();
814 ZEPHIR_SINIT_NVAR(_22$$5);
815 ZVAL_LONG(&_22$$5, 4);
816 ZEPHIR_SINIT_NVAR(_23$$5);
817 ZVAL_LONG(&_23$$5, 0);
818 ZEPHIR_SINIT_NVAR(_24$$5);
819 ZVAL_LONG(&_24$$5, 0);
820 ZEPHIR_SINIT_NVAR(_25$$5);
821 ZVAL_LONG(&_25$$5, 0);
822 ZEPHIR_SINIT_NVAR(_26$$5);
823 ZVAL_LONG(&_26$$5, dst_opacity);
824 ZEPHIR_CALL_FUNCTION(NULL, "imagefilter", &_27, 288, line, &_22$$5, &_23$$5, &_24$$5, &_25$$5, &_26$$5);
825 zephir_check_call_status();
826 _28$$5 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
827 ZEPHIR_SINIT_NVAR(_22$$5);
828 ZVAL_LONG(&_22$$5, 0);
829 ZEPHIR_SINIT_NVAR(_23$$5);
830 ZVAL_LONG(&_23$$5, dst_y);
831 ZEPHIR_SINIT_NVAR(_24$$5);
832 ZVAL_LONG(&_24$$5, 0);
833 ZEPHIR_SINIT_NVAR(_25$$5);
834 ZVAL_LONG(&_25$$5, 0);
835 ZEPHIR_SINIT_NVAR(_26$$5);
836 ZVAL_LONG(&_26$$5, 1);
837 ZEPHIR_CALL_FUNCTION(NULL, "imagecopy", NULL, 285, reflection, line, &_22$$5, &_23$$5, &_24$$5, &_25$$5, _28$$5, &_26$$5);
838 zephir_check_call_status();
839 offset++;
840 }
841 _29 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
842 ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 276, _29);
843 zephir_check_call_status();
844 zephir_update_property_this(getThis(), SL("_image"), reflection TSRMLS_CC);
845 ZEPHIR_CALL_FUNCTION(&_30, "imagesx", NULL, 278, reflection);
846 zephir_check_call_status();
847 zephir_update_property_this(getThis(), SL("_width"), _30 TSRMLS_CC);
848 ZEPHIR_CALL_FUNCTION(&_31, "imagesy", NULL, 279, reflection);
849 zephir_check_call_status();
850 zephir_update_property_this(getThis(), SL("_height"), _31 TSRMLS_CC);
851 ZEPHIR_MM_RESTORE();
852
853 }
854
PHP_METHOD(Phalcon_Image_Adapter_Gd,_watermark)855 PHP_METHOD(Phalcon_Image_Adapter_Gd, _watermark) {
856
857 zend_long offsetX, offsetY, opacity, ZEPHIR_LAST_CALL_STATUS, width = 0, height = 0;
858 zval *watermark, *offsetX_param = NULL, *offsetY_param = NULL, *opacity_param = NULL, *overlay = NULL, *color = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_9, *_10, _11, _12, _13, _14, _15, _16, *_17 = NULL, *_3$$3, _4$$3 = zval_used_for_init, *_5$$3 = NULL, _6$$3 = zval_used_for_init, _7$$3 = zval_used_for_init, _8$$3 = zval_used_for_init;
859
860 ZEPHIR_MM_GROW();
861 zephir_fetch_params(1, 4, 0, &watermark, &offsetX_param, &offsetY_param, &opacity_param);
862
863 offsetX = zephir_get_intval(offsetX_param);
864 offsetY = zephir_get_intval(offsetY_param);
865 opacity = zephir_get_intval(opacity_param);
866
867
868 ZEPHIR_CALL_METHOD(&_0, watermark, "render", NULL, 0);
869 zephir_check_call_status();
870 ZEPHIR_CALL_FUNCTION(&overlay, "imagecreatefromstring", NULL, 289, _0);
871 zephir_check_call_status();
872 ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 272, overlay, ZEPHIR_GLOBAL(global_true));
873 zephir_check_call_status();
874 ZEPHIR_CALL_FUNCTION(&_1, "imagesx", NULL, 278, overlay);
875 zephir_check_call_status();
876 width = zephir_get_intval(_1);
877 ZEPHIR_CALL_FUNCTION(&_2, "imagesy", NULL, 279, overlay);
878 zephir_check_call_status();
879 height = zephir_get_intval(_2);
880 if (opacity < 100) {
881 ZEPHIR_INIT_VAR(_3$$3);
882 ZEPHIR_SINIT_VAR(_4$$3);
883 ZVAL_DOUBLE(&_4$$3, ((zephir_safe_div_long_long((opacity * 127), 100 TSRMLS_CC)) - (double) (127)));
884 ZEPHIR_CALL_FUNCTION(&_5$$3, "abs", NULL, 213, &_4$$3);
885 zephir_check_call_status();
886 zephir_round(_3$$3, _5$$3, NULL, NULL TSRMLS_CC);
887 opacity = zephir_get_intval(_3$$3);
888 ZEPHIR_SINIT_NVAR(_4$$3);
889 ZVAL_LONG(&_4$$3, 127);
890 ZEPHIR_SINIT_VAR(_6$$3);
891 ZVAL_LONG(&_6$$3, 127);
892 ZEPHIR_SINIT_VAR(_7$$3);
893 ZVAL_LONG(&_7$$3, 127);
894 ZEPHIR_SINIT_VAR(_8$$3);
895 ZVAL_LONG(&_8$$3, opacity);
896 ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 282, overlay, &_4$$3, &_6$$3, &_7$$3, &_8$$3);
897 zephir_check_call_status();
898 ZEPHIR_SINIT_NVAR(_4$$3);
899 ZVAL_LONG(&_4$$3, 3);
900 ZEPHIR_CALL_FUNCTION(NULL, "imagelayereffect", NULL, 290, overlay, &_4$$3);
901 zephir_check_call_status();
902 ZEPHIR_SINIT_NVAR(_4$$3);
903 ZVAL_LONG(&_4$$3, 0);
904 ZEPHIR_SINIT_NVAR(_6$$3);
905 ZVAL_LONG(&_6$$3, 0);
906 ZEPHIR_SINIT_NVAR(_7$$3);
907 ZVAL_LONG(&_7$$3, width);
908 ZEPHIR_SINIT_NVAR(_8$$3);
909 ZVAL_LONG(&_8$$3, height);
910 ZEPHIR_CALL_FUNCTION(NULL, "imagefilledrectangle", NULL, 291, overlay, &_4$$3, &_6$$3, &_7$$3, &_8$$3, color);
911 zephir_check_call_status();
912 }
913 _9 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
914 ZEPHIR_CALL_FUNCTION(NULL, "imagealphablending", NULL, 274, _9, ZEPHIR_GLOBAL(global_true));
915 zephir_check_call_status();
916 _10 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
917 ZEPHIR_SINIT_VAR(_11);
918 ZVAL_LONG(&_11, offsetX);
919 ZEPHIR_SINIT_VAR(_12);
920 ZVAL_LONG(&_12, offsetY);
921 ZEPHIR_SINIT_VAR(_13);
922 ZVAL_LONG(&_13, 0);
923 ZEPHIR_SINIT_VAR(_14);
924 ZVAL_LONG(&_14, 0);
925 ZEPHIR_SINIT_VAR(_15);
926 ZVAL_LONG(&_15, width);
927 ZEPHIR_SINIT_VAR(_16);
928 ZVAL_LONG(&_16, height);
929 ZEPHIR_CALL_FUNCTION(&_17, "imagecopy", NULL, 285, _10, overlay, &_11, &_12, &_13, &_14, &_15, &_16);
930 zephir_check_call_status();
931 if (zephir_is_true(_17)) {
932 ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 276, overlay);
933 zephir_check_call_status();
934 }
935 ZEPHIR_MM_RESTORE();
936
937 }
938
PHP_METHOD(Phalcon_Image_Adapter_Gd,_text)939 PHP_METHOD(Phalcon_Image_Adapter_Gd, _text) {
940
941 zend_bool _9$$3, _10$$3, _11$$3;
942 zend_long offsetX, offsetY, opacity, r, g, b, size, ZEPHIR_LAST_CALL_STATUS, angle = 0, s0, s1, s4, s5, width = 0, height = 0;
943 zval *text_param = NULL, *offsetX_param = NULL, *offsetY_param = NULL, *opacity_param = NULL, *r_param = NULL, *g_param = NULL, *b_param = NULL, *size_param = NULL, *fontfile_param = NULL, *space = NULL, *color = NULL, *_0, _1, *_2 = NULL, *_3$$3 = NULL, *_4$$3 = NULL, _12$$3 = zval_used_for_init, *_13$$3 = NULL, *_14$$3 = NULL, *_17$$3, _18$$3, _19$$3, _20$$3, *_21$$3, *_22$$3, *_23$$3, *_5$$4, *_6$$4, *_7$$4, *_8$$4, *_15$$6, *_16$$7, _24$$8 = zval_used_for_init, *_25$$8 = NULL, *_26$$8 = NULL, *_29$$8, _30$$8 = zval_used_for_init, _31$$8 = zval_used_for_init, _32$$8, *_33$$8, *_27$$9, *_28$$10;
944 zval *text = NULL, *fontfile = NULL;
945
946 ZEPHIR_MM_GROW();
947 zephir_fetch_params(1, 9, 0, &text_param, &offsetX_param, &offsetY_param, &opacity_param, &r_param, &g_param, &b_param, &size_param, &fontfile_param);
948
949 zephir_get_strval(text, text_param);
950 offsetX = zephir_get_intval(offsetX_param);
951 offsetY = zephir_get_intval(offsetY_param);
952 opacity = zephir_get_intval(opacity_param);
953 r = zephir_get_intval(r_param);
954 g = zephir_get_intval(g_param);
955 b = zephir_get_intval(b_param);
956 size = zephir_get_intval(size_param);
957 zephir_get_strval(fontfile, fontfile_param);
958
959
960 s0 = 0;
961 s1 = 0;
962 s4 = 0;
963 s5 = 0;
964 ZEPHIR_INIT_VAR(_0);
965 ZEPHIR_SINIT_VAR(_1);
966 ZVAL_DOUBLE(&_1, ((zephir_safe_div_long_long((opacity * 127), 100 TSRMLS_CC)) - (double) (127)));
967 ZEPHIR_CALL_FUNCTION(&_2, "abs", NULL, 213, &_1);
968 zephir_check_call_status();
969 zephir_round(_0, _2, NULL, NULL TSRMLS_CC);
970 opacity = zephir_get_intval(_0);
971 if (!(!fontfile) && Z_STRLEN_P(fontfile)) {
972 ZEPHIR_INIT_VAR(_3$$3);
973 ZVAL_LONG(_3$$3, size);
974 ZEPHIR_INIT_VAR(_4$$3);
975 ZVAL_LONG(_4$$3, 0);
976 ZEPHIR_CALL_FUNCTION(&space, "imagettfbbox", NULL, 0, _3$$3, _4$$3, fontfile, text);
977 zephir_check_call_status();
978 if (zephir_array_isset_long(space, 0)) {
979 ZEPHIR_OBS_VAR(_5$$4);
980 zephir_array_fetch_long(&_5$$4, space, 0, PH_NOISY, "phalcon/image/adapter/gd.zep", 350 TSRMLS_CC);
981 s0 = zephir_get_intval(_5$$4);
982 ZEPHIR_OBS_VAR(_6$$4);
983 zephir_array_fetch_long(&_6$$4, space, 1, PH_NOISY, "phalcon/image/adapter/gd.zep", 351 TSRMLS_CC);
984 s1 = zephir_get_intval(_6$$4);
985 ZEPHIR_OBS_VAR(_7$$4);
986 zephir_array_fetch_long(&_7$$4, space, 4, PH_NOISY, "phalcon/image/adapter/gd.zep", 352 TSRMLS_CC);
987 s4 = zephir_get_intval(_7$$4);
988 ZEPHIR_OBS_VAR(_8$$4);
989 zephir_array_fetch_long(&_8$$4, space, 5, PH_NOISY, "phalcon/image/adapter/gd.zep", 353 TSRMLS_CC);
990 s5 = zephir_get_intval(_8$$4);
991 }
992 _9$$3 = !s0;
993 if (!(_9$$3)) {
994 _9$$3 = !s1;
995 }
996 _10$$3 = _9$$3;
997 if (!(_10$$3)) {
998 _10$$3 = !s4;
999 }
1000 _11$$3 = _10$$3;
1001 if (!(_11$$3)) {
1002 _11$$3 = !s5;
1003 }
1004 if (_11$$3) {
1005 ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Call to imagettfbbox() failed", "phalcon/image/adapter/gd.zep", 357);
1006 return;
1007 }
1008 ZEPHIR_SINIT_VAR(_12$$3);
1009 ZVAL_LONG(&_12$$3, (s4 - s0));
1010 ZEPHIR_CALL_FUNCTION(&_13$$3, "abs", NULL, 213, &_12$$3);
1011 zephir_check_call_status();
1012 width = (zephir_get_numberval(_13$$3) + 10);
1013 ZEPHIR_SINIT_NVAR(_12$$3);
1014 ZVAL_LONG(&_12$$3, (s5 - s1));
1015 ZEPHIR_CALL_FUNCTION(&_14$$3, "abs", NULL, 213, &_12$$3);
1016 zephir_check_call_status();
1017 height = (zephir_get_numberval(_14$$3) + 10);
1018 if (offsetX < 0) {
1019 _15$$6 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
1020 offsetX = ((zephir_get_numberval(_15$$6) - width) + offsetX);
1021 }
1022 if (offsetY < 0) {
1023 _16$$7 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
1024 offsetY = ((zephir_get_numberval(_16$$7) - height) + offsetY);
1025 }
1026 _17$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1027 ZEPHIR_SINIT_NVAR(_12$$3);
1028 ZVAL_LONG(&_12$$3, r);
1029 ZEPHIR_SINIT_VAR(_18$$3);
1030 ZVAL_LONG(&_18$$3, g);
1031 ZEPHIR_SINIT_VAR(_19$$3);
1032 ZVAL_LONG(&_19$$3, b);
1033 ZEPHIR_SINIT_VAR(_20$$3);
1034 ZVAL_LONG(&_20$$3, opacity);
1035 ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 282, _17$$3, &_12$$3, &_18$$3, &_19$$3, &_20$$3);
1036 zephir_check_call_status();
1037 angle = 0;
1038 _21$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1039 ZEPHIR_INIT_NVAR(_3$$3);
1040 ZVAL_LONG(_3$$3, size);
1041 ZEPHIR_INIT_NVAR(_4$$3);
1042 ZVAL_LONG(_4$$3, angle);
1043 ZEPHIR_INIT_VAR(_22$$3);
1044 ZVAL_LONG(_22$$3, offsetX);
1045 ZEPHIR_INIT_VAR(_23$$3);
1046 ZVAL_LONG(_23$$3, offsetY);
1047 ZEPHIR_CALL_FUNCTION(NULL, "imagettftext", NULL, 0, _21$$3, _3$$3, _4$$3, _22$$3, _23$$3, color, fontfile, text);
1048 zephir_check_call_status();
1049 } else {
1050 ZEPHIR_SINIT_VAR(_24$$8);
1051 ZVAL_LONG(&_24$$8, size);
1052 ZEPHIR_CALL_FUNCTION(&_25$$8, "imagefontwidth", NULL, 292, &_24$$8);
1053 zephir_check_call_status();
1054 width = (zephir_get_intval(_25$$8) * zephir_fast_strlen_ev(text));
1055 ZEPHIR_SINIT_NVAR(_24$$8);
1056 ZVAL_LONG(&_24$$8, size);
1057 ZEPHIR_CALL_FUNCTION(&_26$$8, "imagefontheight", NULL, 293, &_24$$8);
1058 zephir_check_call_status();
1059 height = zephir_get_intval(_26$$8);
1060 if (offsetX < 0) {
1061 _27$$9 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
1062 offsetX = ((zephir_get_numberval(_27$$9) - width) + offsetX);
1063 }
1064 if (offsetY < 0) {
1065 _28$$10 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
1066 offsetY = ((zephir_get_numberval(_28$$10) - height) + offsetY);
1067 }
1068 _29$$8 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1069 ZEPHIR_SINIT_NVAR(_24$$8);
1070 ZVAL_LONG(&_24$$8, r);
1071 ZEPHIR_SINIT_VAR(_30$$8);
1072 ZVAL_LONG(&_30$$8, g);
1073 ZEPHIR_SINIT_VAR(_31$$8);
1074 ZVAL_LONG(&_31$$8, b);
1075 ZEPHIR_SINIT_VAR(_32$$8);
1076 ZVAL_LONG(&_32$$8, opacity);
1077 ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 282, _29$$8, &_24$$8, &_30$$8, &_31$$8, &_32$$8);
1078 zephir_check_call_status();
1079 _33$$8 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1080 ZEPHIR_SINIT_NVAR(_24$$8);
1081 ZVAL_LONG(&_24$$8, size);
1082 ZEPHIR_SINIT_NVAR(_30$$8);
1083 ZVAL_LONG(&_30$$8, offsetX);
1084 ZEPHIR_SINIT_NVAR(_31$$8);
1085 ZVAL_LONG(&_31$$8, offsetY);
1086 ZEPHIR_CALL_FUNCTION(NULL, "imagestring", NULL, 294, _33$$8, &_24$$8, &_30$$8, &_31$$8, text, color);
1087 zephir_check_call_status();
1088 }
1089 ZEPHIR_MM_RESTORE();
1090
1091 }
1092
PHP_METHOD(Phalcon_Image_Adapter_Gd,_mask)1093 PHP_METHOD(Phalcon_Image_Adapter_Gd, _mask) {
1094
1095 zend_bool _10;
1096 zephir_fcall_cache_entry *_26 = NULL, *_27 = NULL, *_32 = NULL;
1097 zend_long ZEPHIR_LAST_CALL_STATUS, mask_width = 0, mask_height = 0, x = 0, y = 0, alpha = 0;
1098 zval *mask, *maskImage = NULL, *newimage = NULL, *tempImage = NULL, *color = NULL, *index = NULL, *r = NULL, *g = NULL, *b = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3, *_4, _5 = zval_used_for_init, _6 = zval_used_for_init, _7, _8, *_9, *_11, *_22, *_33, *_12$$3, *_13$$3, *_14$$3, *_15$$3, _16$$3, _17$$3, _18$$3, _19$$3, _20$$3, _21$$3, *_23$$4, _24$$5 = zval_used_for_init, _25$$5 = zval_used_for_init, *_30$$5, *_31$$5, *_28$$6, _29$$6 = zval_used_for_init;
1099
1100 ZEPHIR_MM_GROW();
1101 zephir_fetch_params(1, 1, 0, &mask);
1102
1103
1104
1105 ZEPHIR_CALL_METHOD(&_0, mask, "render", NULL, 0);
1106 zephir_check_call_status();
1107 ZEPHIR_CALL_FUNCTION(&maskImage, "imagecreatefromstring", NULL, 289, _0);
1108 zephir_check_call_status();
1109 ZEPHIR_CALL_FUNCTION(&_1, "imagesx", NULL, 278, maskImage);
1110 zephir_check_call_status();
1111 mask_width = zephir_get_intval(_1);
1112 ZEPHIR_CALL_FUNCTION(&_2, "imagesy", NULL, 279, maskImage);
1113 zephir_check_call_status();
1114 mask_height = zephir_get_intval(_2);
1115 alpha = 127;
1116 ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 272, maskImage, ZEPHIR_GLOBAL(global_true));
1117 zephir_check_call_status();
1118 _3 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
1119 _4 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
1120 ZEPHIR_CALL_METHOD(&newimage, this_ptr, "_create", NULL, 0, _3, _4);
1121 zephir_check_call_status();
1122 ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 272, newimage, ZEPHIR_GLOBAL(global_true));
1123 zephir_check_call_status();
1124 ZEPHIR_SINIT_VAR(_5);
1125 ZVAL_LONG(&_5, 0);
1126 ZEPHIR_SINIT_VAR(_6);
1127 ZVAL_LONG(&_6, 0);
1128 ZEPHIR_SINIT_VAR(_7);
1129 ZVAL_LONG(&_7, 0);
1130 ZEPHIR_SINIT_VAR(_8);
1131 ZVAL_LONG(&_8, alpha);
1132 ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 282, newimage, &_5, &_6, &_7, &_8);
1133 zephir_check_call_status();
1134 ZEPHIR_SINIT_NVAR(_5);
1135 ZVAL_LONG(&_5, 0);
1136 ZEPHIR_SINIT_NVAR(_6);
1137 ZVAL_LONG(&_6, 0);
1138 ZEPHIR_CALL_FUNCTION(NULL, "imagefill", NULL, 295, newimage, &_5, &_6, color);
1139 zephir_check_call_status();
1140 _9 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
1141 _10 = !ZEPHIR_IS_LONG(_9, mask_width);
1142 if (!(_10)) {
1143 _11 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
1144 _10 = !ZEPHIR_IS_LONG(_11, mask_height);
1145 }
1146 if (_10) {
1147 _12$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
1148 _13$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
1149 ZEPHIR_CALL_FUNCTION(&tempImage, "imagecreatetruecolor", NULL, 273, _12$$3, _13$$3);
1150 zephir_check_call_status();
1151 _14$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
1152 _15$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
1153 ZEPHIR_SINIT_VAR(_16$$3);
1154 ZVAL_LONG(&_16$$3, 0);
1155 ZEPHIR_SINIT_VAR(_17$$3);
1156 ZVAL_LONG(&_17$$3, 0);
1157 ZEPHIR_SINIT_VAR(_18$$3);
1158 ZVAL_LONG(&_18$$3, 0);
1159 ZEPHIR_SINIT_VAR(_19$$3);
1160 ZVAL_LONG(&_19$$3, 0);
1161 ZEPHIR_SINIT_VAR(_20$$3);
1162 ZVAL_LONG(&_20$$3, mask_width);
1163 ZEPHIR_SINIT_VAR(_21$$3);
1164 ZVAL_LONG(&_21$$3, mask_height);
1165 ZEPHIR_CALL_FUNCTION(NULL, "imagecopyresampled", NULL, 277, tempImage, maskImage, &_16$$3, &_17$$3, &_18$$3, &_19$$3, _14$$3, _15$$3, &_20$$3, &_21$$3);
1166 zephir_check_call_status();
1167 ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 276, maskImage);
1168 zephir_check_call_status();
1169 ZEPHIR_CPY_WRT(maskImage, tempImage);
1170 }
1171 x = 0;
1172 while (1) {
1173 _22 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
1174 if (!(ZEPHIR_GT_LONG(_22, x))) {
1175 break;
1176 }
1177 y = 0;
1178 while (1) {
1179 _23$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
1180 if (!(ZEPHIR_GT_LONG(_23$$4, y))) {
1181 break;
1182 }
1183 ZEPHIR_SINIT_NVAR(_24$$5);
1184 ZVAL_LONG(&_24$$5, x);
1185 ZEPHIR_SINIT_NVAR(_25$$5);
1186 ZVAL_LONG(&_25$$5, y);
1187 ZEPHIR_CALL_FUNCTION(&index, "imagecolorat", &_26, 296, maskImage, &_24$$5, &_25$$5);
1188 zephir_check_call_status();
1189 ZEPHIR_CALL_FUNCTION(&color, "imagecolorsforindex", &_27, 297, maskImage, index);
1190 zephir_check_call_status();
1191 if (zephir_array_isset_string(color, SS("red"))) {
1192 zephir_array_fetch_string(&_28$$6, color, SL("red"), PH_NOISY | PH_READONLY, "phalcon/image/adapter/gd.zep", 430 TSRMLS_CC);
1193 ZEPHIR_SINIT_NVAR(_29$$6);
1194 ZVAL_DOUBLE(&_29$$6, zephir_safe_div_zval_long(_28$$6, 2 TSRMLS_CC));
1195 alpha = (127 - zephir_get_intval(&_29$$6));
1196 }
1197 _30$$5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1198 ZEPHIR_SINIT_NVAR(_24$$5);
1199 ZVAL_LONG(&_24$$5, x);
1200 ZEPHIR_SINIT_NVAR(_25$$5);
1201 ZVAL_LONG(&_25$$5, y);
1202 ZEPHIR_CALL_FUNCTION(&index, "imagecolorat", &_26, 296, _30$$5, &_24$$5, &_25$$5);
1203 zephir_check_call_status();
1204 _31$$5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1205 ZEPHIR_CALL_FUNCTION(&color, "imagecolorsforindex", &_27, 297, _31$$5, index);
1206 zephir_check_call_status();
1207 ZEPHIR_OBS_NVAR(r);
1208 zephir_array_fetch_string(&r, color, SL("red"), PH_NOISY, "phalcon/image/adapter/gd.zep", 435 TSRMLS_CC);
1209 ZEPHIR_OBS_NVAR(g);
1210 zephir_array_fetch_string(&g, color, SL("green"), PH_NOISY, "phalcon/image/adapter/gd.zep", 435 TSRMLS_CC);
1211 ZEPHIR_OBS_NVAR(b);
1212 zephir_array_fetch_string(&b, color, SL("blue"), PH_NOISY, "phalcon/image/adapter/gd.zep", 435 TSRMLS_CC);
1213 ZEPHIR_SINIT_NVAR(_24$$5);
1214 ZVAL_LONG(&_24$$5, alpha);
1215 ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 282, newimage, r, g, b, &_24$$5);
1216 zephir_check_call_status();
1217 ZEPHIR_SINIT_NVAR(_24$$5);
1218 ZVAL_LONG(&_24$$5, x);
1219 ZEPHIR_SINIT_NVAR(_25$$5);
1220 ZVAL_LONG(&_25$$5, y);
1221 ZEPHIR_CALL_FUNCTION(NULL, "imagesetpixel", &_32, 298, newimage, &_24$$5, &_25$$5, color);
1222 zephir_check_call_status();
1223 y++;
1224 }
1225 x++;
1226 }
1227 _33 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1228 ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 276, _33);
1229 zephir_check_call_status();
1230 ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 276, maskImage);
1231 zephir_check_call_status();
1232 zephir_update_property_this(getThis(), SL("_image"), newimage TSRMLS_CC);
1233 ZEPHIR_MM_RESTORE();
1234
1235 }
1236
PHP_METHOD(Phalcon_Image_Adapter_Gd,_background)1237 PHP_METHOD(Phalcon_Image_Adapter_Gd, _background) {
1238
1239 zval *r_param = NULL, *g_param = NULL, *b_param = NULL, *opacity_param = NULL, *background = NULL, *color = NULL, *_0, *_1, _2 = zval_used_for_init, _3 = zval_used_for_init, _4 = zval_used_for_init, _5 = zval_used_for_init, *_6, *_7, *_8, *_9 = NULL, *_10$$3;
1240 zend_long r, g, b, opacity, ZEPHIR_LAST_CALL_STATUS;
1241
1242 ZEPHIR_MM_GROW();
1243 zephir_fetch_params(1, 4, 0, &r_param, &g_param, &b_param, &opacity_param);
1244
1245 r = zephir_get_intval(r_param);
1246 g = zephir_get_intval(g_param);
1247 b = zephir_get_intval(b_param);
1248 opacity = zephir_get_intval(opacity_param);
1249
1250
1251 opacity = (long) (((zephir_safe_div_long_long((opacity * 127), 100 TSRMLS_CC)) - (double) (127)));
1252 _0 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
1253 _1 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
1254 ZEPHIR_CALL_METHOD(&background, this_ptr, "_create", NULL, 0, _0, _1);
1255 zephir_check_call_status();
1256 ZEPHIR_SINIT_VAR(_2);
1257 ZVAL_LONG(&_2, r);
1258 ZEPHIR_SINIT_VAR(_3);
1259 ZVAL_LONG(&_3, g);
1260 ZEPHIR_SINIT_VAR(_4);
1261 ZVAL_LONG(&_4, b);
1262 ZEPHIR_SINIT_VAR(_5);
1263 ZVAL_LONG(&_5, opacity);
1264 ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 282, background, &_2, &_3, &_4, &_5);
1265 zephir_check_call_status();
1266 ZEPHIR_CALL_FUNCTION(NULL, "imagealphablending", NULL, 274, background, ZEPHIR_GLOBAL(global_true));
1267 zephir_check_call_status();
1268 _6 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1269 _7 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
1270 _8 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
1271 ZEPHIR_SINIT_NVAR(_2);
1272 ZVAL_LONG(&_2, 0);
1273 ZEPHIR_SINIT_NVAR(_3);
1274 ZVAL_LONG(&_3, 0);
1275 ZEPHIR_SINIT_NVAR(_4);
1276 ZVAL_LONG(&_4, 0);
1277 ZEPHIR_SINIT_NVAR(_5);
1278 ZVAL_LONG(&_5, 0);
1279 ZEPHIR_CALL_FUNCTION(&_9, "imagecopy", NULL, 285, background, _6, &_2, &_3, &_4, &_5, _7, _8);
1280 zephir_check_call_status();
1281 if (zephir_is_true(_9)) {
1282 _10$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1283 ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 276, _10$$3);
1284 zephir_check_call_status();
1285 zephir_update_property_this(getThis(), SL("_image"), background TSRMLS_CC);
1286 }
1287 ZEPHIR_MM_RESTORE();
1288
1289 }
1290
PHP_METHOD(Phalcon_Image_Adapter_Gd,_blur)1291 PHP_METHOD(Phalcon_Image_Adapter_Gd, _blur) {
1292
1293 zephir_fcall_cache_entry *_2 = NULL;
1294 zval *radius_param = NULL, *_0$$3, _1$$3 = zval_used_for_init;
1295 zend_long radius, ZEPHIR_LAST_CALL_STATUS, i = 0;
1296
1297 ZEPHIR_MM_GROW();
1298 zephir_fetch_params(1, 1, 0, &radius_param);
1299
1300 radius = zephir_get_intval(radius_param);
1301
1302
1303 i = 0;
1304 while (1) {
1305 if (!(i < radius)) {
1306 break;
1307 }
1308 _0$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1309 ZEPHIR_SINIT_NVAR(_1$$3);
1310 ZVAL_LONG(&_1$$3, 7);
1311 ZEPHIR_CALL_FUNCTION(NULL, "imagefilter", &_2, 288, _0$$3, &_1$$3);
1312 zephir_check_call_status();
1313 i++;
1314 }
1315 ZEPHIR_MM_RESTORE();
1316
1317 }
1318
PHP_METHOD(Phalcon_Image_Adapter_Gd,_pixelate)1319 PHP_METHOD(Phalcon_Image_Adapter_Gd, _pixelate) {
1320
1321 zephir_fcall_cache_entry *_5 = NULL, *_9 = NULL;
1322 zval *amount_param = NULL, *color = NULL, *_0, *_1$$3, *_2$$4, _3$$4 = zval_used_for_init, _4$$4 = zval_used_for_init, *_6$$4, _7$$4 = zval_used_for_init, _8$$4 = zval_used_for_init;
1323 zend_long amount, ZEPHIR_LAST_CALL_STATUS, x = 0, y = 0, x1 = 0, y1 = 0, x2 = 0, y2 = 0;
1324
1325 ZEPHIR_MM_GROW();
1326 zephir_fetch_params(1, 1, 0, &amount_param);
1327
1328 amount = zephir_get_intval(amount_param);
1329
1330
1331 x = 0;
1332 while (1) {
1333 _0 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
1334 if (!(ZEPHIR_GT_LONG(_0, x))) {
1335 break;
1336 }
1337 y = 0;
1338 while (1) {
1339 _1$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
1340 if (!(ZEPHIR_GT_LONG(_1$$3, y))) {
1341 break;
1342 }
1343 x1 = (x + zephir_safe_div_long_long(amount, 2 TSRMLS_CC));
1344 y1 = (y + zephir_safe_div_long_long(amount, 2 TSRMLS_CC));
1345 _2$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1346 ZEPHIR_SINIT_NVAR(_3$$4);
1347 ZVAL_LONG(&_3$$4, x1);
1348 ZEPHIR_SINIT_NVAR(_4$$4);
1349 ZVAL_LONG(&_4$$4, y1);
1350 ZEPHIR_CALL_FUNCTION(&color, "imagecolorat", &_5, 296, _2$$4, &_3$$4, &_4$$4);
1351 zephir_check_call_status();
1352 x2 = (x + amount);
1353 y2 = (y + amount);
1354 _6$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1355 ZEPHIR_SINIT_NVAR(_3$$4);
1356 ZVAL_LONG(&_3$$4, x);
1357 ZEPHIR_SINIT_NVAR(_4$$4);
1358 ZVAL_LONG(&_4$$4, y);
1359 ZEPHIR_SINIT_NVAR(_7$$4);
1360 ZVAL_LONG(&_7$$4, x2);
1361 ZEPHIR_SINIT_NVAR(_8$$4);
1362 ZVAL_LONG(&_8$$4, y2);
1363 ZEPHIR_CALL_FUNCTION(NULL, "imagefilledrectangle", &_9, 291, _6$$4, &_3$$4, &_4$$4, &_7$$4, &_8$$4, color);
1364 zephir_check_call_status();
1365 y += amount;
1366 }
1367 x += amount;
1368 }
1369 ZEPHIR_MM_RESTORE();
1370
1371 }
1372
PHP_METHOD(Phalcon_Image_Adapter_Gd,_save)1373 PHP_METHOD(Phalcon_Image_Adapter_Gd, _save) {
1374
1375 zend_bool _8;
1376 zend_long quality, ZEPHIR_LAST_CALL_STATUS;
1377 zval *file_param = NULL, *quality_param = NULL, *ext = NULL, _0 = zval_used_for_init, *_2 = NULL, *_3 = NULL, *_7 = NULL, *_9 = NULL, *_15 = NULL, *_19 = NULL, *_23 = NULL, *_27, *_1$$3, *_4$$4, *_5$$4 = NULL, *_6$$4, *_10$$5, *_11$$5 = NULL, *_12$$6, _13$$6, *_14$$9, *_16$$10, *_17$$10 = NULL, *_18$$10, *_20$$11, *_21$$11 = NULL, *_22$$11, *_24$$12, *_25$$12 = NULL, *_26$$12;
1378 zval *file = NULL;
1379
1380 ZEPHIR_MM_GROW();
1381 zephir_fetch_params(1, 2, 0, &file_param, &quality_param);
1382
1383 zephir_get_strval(file, file_param);
1384 quality = zephir_get_intval(quality_param);
1385
1386
1387 ZEPHIR_SINIT_VAR(_0);
1388 ZVAL_LONG(&_0, 4);
1389 ZEPHIR_CALL_FUNCTION(&ext, "pathinfo", NULL, 78, file, &_0);
1390 zephir_check_call_status();
1391 if (!(zephir_is_true(ext))) {
1392 _1$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC);
1393 ZEPHIR_CALL_FUNCTION(&ext, "image_type_to_extension", NULL, 299, _1$$3, ZEPHIR_GLOBAL(global_false));
1394 zephir_check_call_status();
1395 }
1396 ZEPHIR_INIT_VAR(_2);
1397 zephir_fast_strtolower(_2, ext);
1398 ZEPHIR_CPY_WRT(ext, _2);
1399 ZEPHIR_SINIT_NVAR(_0);
1400 ZVAL_STRING(&_0, "gif", 0);
1401 ZEPHIR_CALL_FUNCTION(&_3, "strcmp", NULL, 300, ext, &_0);
1402 zephir_check_call_status();
1403 if (ZEPHIR_IS_LONG(_3, 0)) {
1404 ZEPHIR_INIT_ZVAL_NREF(_4$$4);
1405 ZVAL_LONG(_4$$4, 1);
1406 zephir_update_property_this(getThis(), SL("_type"), _4$$4 TSRMLS_CC);
1407 _4$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC);
1408 ZEPHIR_CALL_FUNCTION(&_5$$4, "image_type_to_mime_type", NULL, 301, _4$$4);
1409 zephir_check_call_status();
1410 zephir_update_property_this(getThis(), SL("_mime"), _5$$4 TSRMLS_CC);
1411 _6$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1412 ZEPHIR_CALL_FUNCTION(NULL, "imagegif", NULL, 302, _6$$4, file);
1413 zephir_check_call_status();
1414 RETURN_MM_BOOL(1);
1415 }
1416 ZEPHIR_SINIT_NVAR(_0);
1417 ZVAL_STRING(&_0, "jpg", 0);
1418 ZEPHIR_CALL_FUNCTION(&_7, "strcmp", NULL, 300, ext, &_0);
1419 zephir_check_call_status();
1420 _8 = ZEPHIR_IS_LONG(_7, 0);
1421 if (!(_8)) {
1422 ZEPHIR_SINIT_NVAR(_0);
1423 ZVAL_STRING(&_0, "jpeg", 0);
1424 ZEPHIR_CALL_FUNCTION(&_9, "strcmp", NULL, 300, ext, &_0);
1425 zephir_check_call_status();
1426 _8 = ZEPHIR_IS_LONG(_9, 0);
1427 }
1428 if (_8) {
1429 ZEPHIR_INIT_ZVAL_NREF(_10$$5);
1430 ZVAL_LONG(_10$$5, 2);
1431 zephir_update_property_this(getThis(), SL("_type"), _10$$5 TSRMLS_CC);
1432 _10$$5 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC);
1433 ZEPHIR_CALL_FUNCTION(&_11$$5, "image_type_to_mime_type", NULL, 301, _10$$5);
1434 zephir_check_call_status();
1435 zephir_update_property_this(getThis(), SL("_mime"), _11$$5 TSRMLS_CC);
1436 if (quality >= 0) {
1437 if (quality < 1) {
1438 quality = 1;
1439 } else if (quality > 100) {
1440 quality = 100;
1441 }
1442 _12$$6 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1443 ZEPHIR_SINIT_VAR(_13$$6);
1444 ZVAL_LONG(&_13$$6, quality);
1445 ZEPHIR_CALL_FUNCTION(NULL, "imagejpeg", NULL, 303, _12$$6, file, &_13$$6);
1446 zephir_check_call_status();
1447 } else {
1448 _14$$9 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1449 ZEPHIR_CALL_FUNCTION(NULL, "imagejpeg", NULL, 303, _14$$9, file);
1450 zephir_check_call_status();
1451 }
1452 RETURN_MM_BOOL(1);
1453 }
1454 ZEPHIR_SINIT_NVAR(_0);
1455 ZVAL_STRING(&_0, "png", 0);
1456 ZEPHIR_CALL_FUNCTION(&_15, "strcmp", NULL, 300, ext, &_0);
1457 zephir_check_call_status();
1458 if (ZEPHIR_IS_LONG(_15, 0)) {
1459 ZEPHIR_INIT_ZVAL_NREF(_16$$10);
1460 ZVAL_LONG(_16$$10, 3);
1461 zephir_update_property_this(getThis(), SL("_type"), _16$$10 TSRMLS_CC);
1462 _16$$10 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC);
1463 ZEPHIR_CALL_FUNCTION(&_17$$10, "image_type_to_mime_type", NULL, 301, _16$$10);
1464 zephir_check_call_status();
1465 zephir_update_property_this(getThis(), SL("_mime"), _17$$10 TSRMLS_CC);
1466 _18$$10 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1467 ZEPHIR_CALL_FUNCTION(NULL, "imagepng", NULL, 304, _18$$10, file);
1468 zephir_check_call_status();
1469 RETURN_MM_BOOL(1);
1470 }
1471 ZEPHIR_SINIT_NVAR(_0);
1472 ZVAL_STRING(&_0, "wbmp", 0);
1473 ZEPHIR_CALL_FUNCTION(&_19, "strcmp", NULL, 300, ext, &_0);
1474 zephir_check_call_status();
1475 if (ZEPHIR_IS_LONG(_19, 0)) {
1476 ZEPHIR_INIT_ZVAL_NREF(_20$$11);
1477 ZVAL_LONG(_20$$11, 15);
1478 zephir_update_property_this(getThis(), SL("_type"), _20$$11 TSRMLS_CC);
1479 _20$$11 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC);
1480 ZEPHIR_CALL_FUNCTION(&_21$$11, "image_type_to_mime_type", NULL, 301, _20$$11);
1481 zephir_check_call_status();
1482 zephir_update_property_this(getThis(), SL("_mime"), _21$$11 TSRMLS_CC);
1483 _22$$11 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1484 ZEPHIR_CALL_FUNCTION(NULL, "imagewbmp", NULL, 305, _22$$11, file);
1485 zephir_check_call_status();
1486 RETURN_MM_BOOL(1);
1487 }
1488 ZEPHIR_SINIT_NVAR(_0);
1489 ZVAL_STRING(&_0, "xbm", 0);
1490 ZEPHIR_CALL_FUNCTION(&_23, "strcmp", NULL, 300, ext, &_0);
1491 zephir_check_call_status();
1492 if (ZEPHIR_IS_LONG(_23, 0)) {
1493 ZEPHIR_INIT_ZVAL_NREF(_24$$12);
1494 ZVAL_LONG(_24$$12, 16);
1495 zephir_update_property_this(getThis(), SL("_type"), _24$$12 TSRMLS_CC);
1496 _24$$12 = zephir_fetch_nproperty_this(this_ptr, SL("_type"), PH_NOISY_CC);
1497 ZEPHIR_CALL_FUNCTION(&_25$$12, "image_type_to_mime_type", NULL, 301, _24$$12);
1498 zephir_check_call_status();
1499 zephir_update_property_this(getThis(), SL("_mime"), _25$$12 TSRMLS_CC);
1500 _26$$12 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1501 ZEPHIR_CALL_FUNCTION(NULL, "imagexbm", NULL, 306, _26$$12, file);
1502 zephir_check_call_status();
1503 RETURN_MM_BOOL(1);
1504 }
1505 ZEPHIR_INIT_NVAR(_2);
1506 object_init_ex(_2, phalcon_image_exception_ce);
1507 ZEPHIR_INIT_VAR(_27);
1508 ZEPHIR_CONCAT_SVS(_27, "Installed GD does not support '", ext, "' images");
1509 ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 9, _27);
1510 zephir_check_call_status();
1511 zephir_throw_exception_debug(_2, "phalcon/image/adapter/gd.zep", 554 TSRMLS_CC);
1512 ZEPHIR_MM_RESTORE();
1513 return;
1514
1515 }
1516
PHP_METHOD(Phalcon_Image_Adapter_Gd,_render)1517 PHP_METHOD(Phalcon_Image_Adapter_Gd, _render) {
1518
1519 zend_bool _5;
1520 zend_long quality, ZEPHIR_LAST_CALL_STATUS;
1521 zval *ext_param = NULL, *quality_param = NULL, *_0, _1 = zval_used_for_init, *_2 = NULL, *_4 = NULL, *_6 = NULL, *_9 = NULL, *_11 = NULL, *_13 = NULL, *_15, *_3$$3, *_7$$4, _8$$4, *_10$$5, *_12$$6, *_14$$7;
1522 zval *ext = NULL, *_16;
1523
1524 ZEPHIR_MM_GROW();
1525 zephir_fetch_params(1, 2, 0, &ext_param, &quality_param);
1526
1527 zephir_get_strval(ext, ext_param);
1528 quality = zephir_get_intval(quality_param);
1529
1530
1531 ZEPHIR_INIT_VAR(_0);
1532 zephir_fast_strtolower(_0, ext);
1533 zephir_get_strval(ext, _0);
1534 ZEPHIR_CALL_FUNCTION(NULL, "ob_start", NULL, 140);
1535 zephir_check_call_status();
1536 ZEPHIR_SINIT_VAR(_1);
1537 ZVAL_STRING(&_1, "gif", 0);
1538 ZEPHIR_CALL_FUNCTION(&_2, "strcmp", NULL, 300, ext, &_1);
1539 zephir_check_call_status();
1540 if (ZEPHIR_IS_LONG(_2, 0)) {
1541 _3$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1542 ZEPHIR_CALL_FUNCTION(NULL, "imagegif", NULL, 302, _3$$3);
1543 zephir_check_call_status();
1544 ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", NULL, 307);
1545 zephir_check_call_status();
1546 RETURN_MM();
1547 }
1548 ZEPHIR_SINIT_NVAR(_1);
1549 ZVAL_STRING(&_1, "jpg", 0);
1550 ZEPHIR_CALL_FUNCTION(&_4, "strcmp", NULL, 300, ext, &_1);
1551 zephir_check_call_status();
1552 _5 = ZEPHIR_IS_LONG(_4, 0);
1553 if (!(_5)) {
1554 ZEPHIR_SINIT_NVAR(_1);
1555 ZVAL_STRING(&_1, "jpeg", 0);
1556 ZEPHIR_CALL_FUNCTION(&_6, "strcmp", NULL, 300, ext, &_1);
1557 zephir_check_call_status();
1558 _5 = ZEPHIR_IS_LONG(_6, 0);
1559 }
1560 if (_5) {
1561 _7$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1562 ZEPHIR_SINIT_VAR(_8$$4);
1563 ZVAL_LONG(&_8$$4, quality);
1564 ZEPHIR_CALL_FUNCTION(NULL, "imagejpeg", NULL, 303, _7$$4, ZEPHIR_GLOBAL(global_null), &_8$$4);
1565 zephir_check_call_status();
1566 ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", NULL, 307);
1567 zephir_check_call_status();
1568 RETURN_MM();
1569 }
1570 ZEPHIR_SINIT_NVAR(_1);
1571 ZVAL_STRING(&_1, "png", 0);
1572 ZEPHIR_CALL_FUNCTION(&_9, "strcmp", NULL, 300, ext, &_1);
1573 zephir_check_call_status();
1574 if (ZEPHIR_IS_LONG(_9, 0)) {
1575 _10$$5 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1576 ZEPHIR_CALL_FUNCTION(NULL, "imagepng", NULL, 304, _10$$5);
1577 zephir_check_call_status();
1578 ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", NULL, 307);
1579 zephir_check_call_status();
1580 RETURN_MM();
1581 }
1582 ZEPHIR_SINIT_NVAR(_1);
1583 ZVAL_STRING(&_1, "wbmp", 0);
1584 ZEPHIR_CALL_FUNCTION(&_11, "strcmp", NULL, 300, ext, &_1);
1585 zephir_check_call_status();
1586 if (ZEPHIR_IS_LONG(_11, 0)) {
1587 _12$$6 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1588 ZEPHIR_CALL_FUNCTION(NULL, "imagewbmp", NULL, 305, _12$$6);
1589 zephir_check_call_status();
1590 ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", NULL, 307);
1591 zephir_check_call_status();
1592 RETURN_MM();
1593 }
1594 ZEPHIR_SINIT_NVAR(_1);
1595 ZVAL_STRING(&_1, "xbm", 0);
1596 ZEPHIR_CALL_FUNCTION(&_13, "strcmp", NULL, 300, ext, &_1);
1597 zephir_check_call_status();
1598 if (ZEPHIR_IS_LONG(_13, 0)) {
1599 _14$$7 = zephir_fetch_nproperty_this(this_ptr, SL("_image"), PH_NOISY_CC);
1600 ZEPHIR_CALL_FUNCTION(NULL, "imagexbm", NULL, 306, _14$$7, ZEPHIR_GLOBAL(global_null));
1601 zephir_check_call_status();
1602 ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", NULL, 307);
1603 zephir_check_call_status();
1604 RETURN_MM();
1605 }
1606 ZEPHIR_INIT_VAR(_15);
1607 object_init_ex(_15, phalcon_image_exception_ce);
1608 ZEPHIR_INIT_VAR(_16);
1609 ZEPHIR_CONCAT_SVS(_16, "Installed GD does not support '", ext, "' images");
1610 ZEPHIR_CALL_METHOD(NULL, _15, "__construct", NULL, 9, _16);
1611 zephir_check_call_status();
1612 zephir_throw_exception_debug(_15, "phalcon/image/adapter/gd.zep", 582 TSRMLS_CC);
1613 ZEPHIR_MM_RESTORE();
1614 return;
1615
1616 }
1617
PHP_METHOD(Phalcon_Image_Adapter_Gd,_create)1618 PHP_METHOD(Phalcon_Image_Adapter_Gd, _create) {
1619
1620 zval *width_param = NULL, *height_param = NULL, *image = NULL, _0, _1;
1621 zend_long width, height, ZEPHIR_LAST_CALL_STATUS;
1622
1623 ZEPHIR_MM_GROW();
1624 zephir_fetch_params(1, 2, 0, &width_param, &height_param);
1625
1626 width = zephir_get_intval(width_param);
1627 height = zephir_get_intval(height_param);
1628
1629
1630 ZEPHIR_SINIT_VAR(_0);
1631 ZVAL_LONG(&_0, width);
1632 ZEPHIR_SINIT_VAR(_1);
1633 ZVAL_LONG(&_1, height);
1634 ZEPHIR_CALL_FUNCTION(&image, "imagecreatetruecolor", NULL, 273, &_0, &_1);
1635 zephir_check_call_status();
1636 ZEPHIR_CALL_FUNCTION(NULL, "imagealphablending", NULL, 274, image, ZEPHIR_GLOBAL(global_false));
1637 zephir_check_call_status();
1638 ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 272, image, ZEPHIR_GLOBAL(global_true));
1639 zephir_check_call_status();
1640 RETURN_CCTOR(image);
1641
1642 }
1643
PHP_METHOD(Phalcon_Image_Adapter_Gd,__destruct)1644 PHP_METHOD(Phalcon_Image_Adapter_Gd, __destruct) {
1645
1646 zval *image = NULL;
1647 zend_long ZEPHIR_LAST_CALL_STATUS;
1648
1649 ZEPHIR_MM_GROW();
1650
1651 ZEPHIR_OBS_VAR(image);
1652 zephir_read_property_this(&image, this_ptr, SL("_image"), PH_NOISY_CC);
1653 if (Z_TYPE_P(image) == IS_RESOURCE) {
1654 ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 276, image);
1655 zephir_check_call_status();
1656 }
1657 ZEPHIR_MM_RESTORE();
1658
1659 }
1660
1661