xref: /imagick/imagick_helpers.c (revision 3998cfcf)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 5 / Imagick											  |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 2006-2013 Mikko Koppanen, Scott MacVicar				  |
6    | ImageMagick (c) ImageMagick Studio LLC								  |
7    +----------------------------------------------------------------------+
8    | This source file is subject to version 3.01 of the PHP license,	  |
9    | that is bundled with this package in the file LICENSE, and is		  |
10    | available through the world-wide-web at the following url:			  |
11    | http://www.php.net/license/3_01.txt								  |
12    | If you did not receive a copy of the PHP license and are unable to	  |
13    | obtain it through the world-wide-web, please send a note to		  |
14    | license@php.net so we can mail you a copy immediately.				  |
15    +----------------------------------------------------------------------+
16    | Author: Mikko Kopppanen <mkoppanen@php.net>						  |
17    |		 Scott MacVicar <scottmac@php.net>							  |
18    +----------------------------------------------------------------------+
19 */
20 
21 #include "php_imagick.h"
22 #include "php_imagick_defs.h"
23 #include "php_imagick_macros.h"
24 #include "php_imagick_helpers.h"
25 
php_imagick_progress_monitor(const char * text,const MagickOffsetType offset,const MagickSizeType span,void * client_data)26 MagickBooleanType php_imagick_progress_monitor(const char *text, const MagickOffsetType offset, const MagickSizeType span, void *client_data)
27 {
28 	FILE *fp;
29 	php_imagick_object *intern = (php_imagick_object *)client_data;
30 
31 	if (!intern) {
32 		return MagickFalse;
33 	}
34 
35 	if (!intern->progress_monitor_name) {
36 		return MagickFalse;
37 	}
38 
39 	fp = fopen(intern->progress_monitor_name, "a+");
40 
41 	if (!fp) {
42 		return MagickFalse;
43 	}
44 
45 	fprintf(fp, "text: %s, offset: %lld, span: %lld\n", text, offset, span);
46 	fclose(fp);
47 	return MagickTrue;
48 }
49 
php_imagick_cleanup_progress_callback(php_imagick_callback * progress_callback TSRMLS_DC)50 void php_imagick_cleanup_progress_callback(php_imagick_callback* progress_callback TSRMLS_DC) {
51 
52 	if (progress_callback) {
53 		if (progress_callback->previous_callback) {
54 			php_imagick_cleanup_progress_callback(progress_callback->previous_callback TSRMLS_CC);
55 			efree(progress_callback->previous_callback);
56 		}
57 
58 #if PHP_VERSION_ID >= 70000
59 		zval_ptr_dtor(&progress_callback->user_callback);
60 #else
61 		zval_ptr_dtor(&progress_callback->user_callback);
62 #endif
63 	}
64 }
65 
php_imagick_progress_monitor_callable(const char * text,const MagickOffsetType offset,const MagickSizeType span,void * userData)66 MagickBooleanType php_imagick_progress_monitor_callable(const char *text, const MagickOffsetType offset, const MagickSizeType span, void *userData)
67 {
68 	int error;
69 	zend_fcall_info fci;
70 	zend_fcall_info_cache fci_cache;
71 
72 #if PHP_VERSION_ID >= 70000
73 	zval zargs[2];
74 	zval retval;
75 #else
76 	zval **zargs[2];
77 	zval *retval_ptr;
78 #endif
79 
80 	//We can get the data both via the passed param and via
81 	//IMAGICK_G(progress_callback) - this should be quicker
82 	php_imagick_callback *callback = (php_imagick_callback*)userData;
83 
84 	// This suppresses an 'unused parameter' warning.
85 	// We could maybe use text.
86 	(void)text;
87 
88 #if PHP_VERSION_ID >= 70000 && defined(ZTS)
89 	if( NULL == tsrm_get_ls_cache() ) {
90 		return MagickTrue;
91 	}
92 #endif
93 
94 #if PHP_VERSION_ID < 70000
95 	TSRMLS_FETCH_FROM_CTX(callback->thread_ctx);
96 #endif
97 	fci_cache = empty_fcall_info_cache;
98 
99 	fci = empty_fcall_info;
100 	fci.size = sizeof(fci);
101 
102 #if PHP_VERSION_ID < 70100
103 	fci.function_table = EG(function_table);
104 #endif
105 #if PHP_VERSION_ID >= 70000
106 	//fci.function_name = *callback->user_callback;
107 	ZVAL_COPY_VALUE(&fci.function_name, &callback->user_callback);
108 	fci.retval = &retval;
109 #else
110 	retval_ptr = NULL;
111 	fci.function_name = callback->user_callback;
112 	fci.retval_ptr_ptr = &retval_ptr;
113 #endif
114 	fci.param_count = 2;
115 	fci.params = zargs;
116 
117 #if PHP_VERSION_ID >= 70000
118 	ZVAL_LONG(&zargs[0], offset);
119     ZVAL_LONG(&zargs[1], span);
120 #else
121 	zargs[0] = emalloc(sizeof(zval *));
122 	MAKE_STD_ZVAL(*zargs[0]);
123 	ZVAL_LONG(*zargs[0], offset);
124 
125 	zargs[1] = emalloc(sizeof(zval *));
126 	MAKE_STD_ZVAL(*zargs[1]);
127 	ZVAL_LONG(*zargs[1], span);
128 #endif
129 
130 	error = zend_call_function(&fci, &fci_cache TSRMLS_CC);
131 
132 	if (error == FAILURE) {
133 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "An error occurred while invoking the callback");
134 		//Abort processing as user callback is no longer callable
135 		return MagickFalse;
136 	}
137 #if PHP_VERSION_ID >= 70000
138 	if (Z_TYPE(retval) == IS_FALSE) {
139 		//User returned false - tell Imagick to abort processing.
140 		return MagickFalse;
141 	}
142 #else
143 	zval_ptr_dtor(zargs[0]);
144 	zval_ptr_dtor(zargs[1]);
145 
146 	if (retval_ptr) {
147 		if (Z_TYPE_P(retval_ptr) == IS_BOOL) {
148 			if (Z_LVAL_P(retval_ptr) == 0) {
149 				//User returned false - tell Imagick to abort processing.
150 				return MagickFalse;
151 			}
152 		}
153 	}
154 #endif
155 
156 	return MagickTrue;
157 }
158 
159 /* This is not universally safe to use, but is safe enough for values that will
160    be encountered for image dimensions.
161 */
im_round_helper(double value)162 static inline double im_round_helper(double value) {
163 	if (value >= 0.0) {
164 		// Prevent zero width/height images
165 		if (value < 1) {
166 			return 1;
167 		}
168 		return floor(value + 0.5);
169 	} else {
170 		return ceil(value - 0.5);
171 	}
172 }
173 
174 
php_imagick_thumbnail_dimensions(MagickWand * magick_wand,zend_bool bestfit,im_long desired_width,im_long desired_height,im_long * new_width,im_long * new_height,zend_bool legacy)175 zend_bool php_imagick_thumbnail_dimensions(MagickWand *magick_wand, zend_bool bestfit, im_long desired_width, im_long desired_height, im_long *new_width, im_long *new_height, zend_bool legacy)
176 {
177 	im_long orig_width, orig_height;
178 
179 	orig_width  = MagickGetImageWidth(magick_wand);
180 	orig_height = MagickGetImageHeight(magick_wand);
181 
182 	if ((orig_width == desired_width) && (orig_height == desired_height)) {
183 		*new_width  = desired_width;
184 		*new_height = desired_height;
185 		return 1;
186 	}
187 
188 	if (bestfit) {
189 		double ratio_x, ratio_y;
190 
191 		if (desired_width <= 0 || desired_height <= 0) {
192 			return 0;
193 		}
194 
195 		ratio_x = (double) desired_width  / (double) orig_width;
196 		ratio_y = (double) desired_height / (double) orig_height;
197 
198 		//in the case of square images there should be no rounding error
199 		if (ratio_x == ratio_y) {
200 			*new_width  = desired_width;
201 			*new_height = desired_height;
202 		} else if (ratio_x < ratio_y) {
203 			*new_width  = desired_width;
204 			if (legacy) {
205 				*new_height = ratio_x * ((double) orig_height);
206 			}
207 			else {
208 				*new_height = im_round_helper(ratio_x * ((double) orig_height));
209 			}
210 		} else {
211 			*new_height = desired_height;
212 			if (legacy) {
213 				*new_width  = ratio_y * ((double) orig_width);
214 			}
215 			else {
216 				*new_width  = im_round_helper(ratio_y * ((double) orig_width));
217 			}
218 		}
219 		*new_width  = (*new_width < 1)  ? 1 : *new_width;
220 		*new_height = (*new_height < 1) ? 1 : *new_height;
221 
222 	} else {
223 		double ratio;
224 
225 		if (desired_width <= 0 && desired_height <= 0) {
226 			return 0;
227 		}
228 
229 		if (desired_width <= 0 || desired_height <= 0) {
230 			if (desired_width <= 0) {
231 				ratio       = (double) orig_height / (double) desired_height;
232 				if (legacy) {
233 					*new_width  = ((double) orig_width) / ratio;
234 				}
235 				else {
236 					*new_width  = im_round_helper(((double) orig_width) / ratio);
237 				}
238 				*new_height = desired_height;
239 			} else {
240 				ratio       = (double) orig_width / (double) desired_width;
241 				if (legacy) {
242 					*new_height = ((double) orig_height) / ratio;
243 				}
244 				else {
245 					*new_height = im_round_helper(((double) orig_height) / ratio);
246 				}
247 				*new_width  = desired_width;
248 			}
249 		} else {
250 			*new_width  = desired_width;
251 			*new_height = desired_height;
252 		}
253 	}
254 	return 1;
255 }
256 
php_imagick_validate_map(const char * map TSRMLS_DC)257 zend_bool php_imagick_validate_map(const char *map TSRMLS_DC)
258 {
259 	zend_bool match;
260 	const char *p = map;
261 	char allow_map[] = { 'R', 'G', 'B',
262 						 'A', 'O', 'C',
263 						 'Y', 'M', 'K',
264 						 'I', 'P' };
265 
266 	while (*p != '\0') {
267 		char *it = allow_map;
268 		match = 0;
269 		while(*it != '\0') {
270 			if (*(it++) == *p) {
271 				match = 1;
272 				break;
273 			}
274 		}
275 		if (!match) {
276 			return 0;
277 		}
278 		p++;
279 	}
280 	return 1;
281 }
282 
php_imagick_zval_to_double_array(zval * param_array,im_long * num_elements TSRMLS_DC)283 double *php_imagick_zval_to_double_array(zval *param_array, im_long *num_elements TSRMLS_DC)
284 {
285 	double *double_array;
286 	long i = 0;
287 
288 #if PHP_VERSION_ID >= 70000
289 	zval *pzvalue;
290 #else
291 	zval **ppzval;
292 #endif
293 
294 	*num_elements = zend_hash_num_elements(Z_ARRVAL_P(param_array));
295 
296 	if (*num_elements == 0) {
297 		return NULL;
298 	}
299 
300 	double_array = ecalloc(*num_elements, sizeof(double));
301 
302 #if PHP_VERSION_ID >= 70000
303 	ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(param_array), pzvalue) {
304 		ZVAL_DEREF(pzvalue);
305 		double_array[i] = zval_get_double(pzvalue);
306 		i++;
307 	} ZEND_HASH_FOREACH_END();
308 #else
309 	for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(param_array));
310 			zend_hash_get_current_data(Z_ARRVAL_P(param_array), (void **) &ppzval) == SUCCESS;
311 			zend_hash_move_forward(Z_ARRVAL_P(param_array)), i++)
312 	{
313 		zval tmp_zval, *tmp_pzval;
314 		double value = 0.0;
315 
316 		if (Z_TYPE_PP(ppzval) == IS_DOUBLE) {
317 			value = Z_DVAL_PP(ppzval);
318 		}
319 		else {
320 			tmp_zval = **ppzval;
321 			zval_copy_ctor(&tmp_zval);
322 			tmp_pzval = &tmp_zval;
323 			convert_to_double(tmp_pzval);
324 
325 			value = Z_DVAL_P(tmp_pzval);
326 			zval_dtor (tmp_pzval);
327 		}
328 		double_array[i] = value;
329 	}
330 #endif
331 	return double_array;
332 }
333 
php_imagick_zval_to_long_array(zval * param_array,im_long * num_elements TSRMLS_DC)334 im_long *php_imagick_zval_to_long_array(zval *param_array, im_long *num_elements TSRMLS_DC)
335 {
336 	im_long *long_array;
337 	im_long i = 0;
338 
339 #if PHP_VERSION_ID >= 70000
340 	zval *pzvalue;
341 #else
342 	zval **ppzval;
343 #endif
344 
345 	*num_elements = zend_hash_num_elements(Z_ARRVAL_P(param_array));
346 
347 	if (*num_elements == 0) {
348 		return NULL;
349 	}
350 
351 	long_array = ecalloc(*num_elements, sizeof(im_long));
352 
353 #if PHP_VERSION_ID >= 70000
354 	ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(param_array), pzvalue) {
355 		ZVAL_DEREF(pzvalue);
356 		long_array[i] = zval_get_long(pzvalue);
357 		i++;
358 	} ZEND_HASH_FOREACH_END();
359 #else
360 	for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(param_array));
361 			zend_hash_get_current_data(Z_ARRVAL_P(param_array), (void **) &ppzval) == SUCCESS;
362 			zend_hash_move_forward(Z_ARRVAL_P(param_array)), i++)
363 	{
364 		zval tmp_zval, *tmp_pzval;
365  		im_long value = 0;
366 
367 		if (Z_TYPE_PP(ppzval) == IS_DOUBLE) {
368 			value = Z_LVAL_PP(ppzval);
369 		}
370 		else {
371 			tmp_zval = **ppzval;
372 			zval_copy_ctor(&tmp_zval);
373 			tmp_pzval = &tmp_zval;
374 			convert_to_long(tmp_pzval);
375 
376 			value = Z_LVAL_P(tmp_pzval);
377 			zval_dtor (tmp_pzval);
378 		}
379 		long_array[i] = value;
380 	}
381 #endif
382 
383 	return long_array;
384 }
385 
php_imagick_zval_to_char_array(zval * param_array,im_long * num_elements TSRMLS_DC)386 unsigned char *php_imagick_zval_to_char_array(zval *param_array, im_long *num_elements TSRMLS_DC)
387 {
388 	unsigned char *char_array;
389 	im_long i = 0;
390 
391 #if PHP_VERSION_ID >= 70000
392 	zval *pzvalue;
393 #else
394 	zval **ppzval;
395 #endif
396 
397 	*num_elements = zend_hash_num_elements(Z_ARRVAL_P(param_array));
398 
399 	if (*num_elements == 0) {
400 		return NULL;
401 	}
402 
403 	char_array = ecalloc(*num_elements, sizeof(unsigned char));
404 
405 #if PHP_VERSION_ID >= 70000
406 	ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(param_array), pzvalue) {
407 		ZVAL_DEREF(pzvalue);
408 		char_array[i] = zval_get_long(pzvalue);
409 		i++;
410 	} ZEND_HASH_FOREACH_END();
411 #else
412 	for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(param_array));
413 			zend_hash_get_current_data(Z_ARRVAL_P(param_array), (void **) &ppzval) == SUCCESS;
414 			zend_hash_move_forward(Z_ARRVAL_P(param_array)), i++)
415 	{
416 		zval tmp_zval, *tmp_pzval;
417 		im_long value = 0;
418 		if (Z_TYPE_PP(ppzval) == IS_DOUBLE) {
419 			value = Z_LVAL_PP(ppzval);
420 		}
421 		else {
422 			tmp_zval = **ppzval;
423 			zval_copy_ctor(&tmp_zval);
424 			tmp_pzval = &tmp_zval;
425 			convert_to_long(tmp_pzval);
426 
427 			value = Z_LVAL_P(tmp_pzval);
428 			zval_dtor (tmp_pzval);
429 		}
430 		char_array[i] = value;
431 	}
432 #endif
433 
434 	return char_array;
435 }
436 
php_imagick_check_font(char * font,int font_len TSRMLS_DC)437 zend_bool php_imagick_check_font(char *font, int font_len TSRMLS_DC)
438 {
439 	zend_bool retval = 0;
440 	char **fonts;
441 	unsigned long i = 0;
442 	size_t num_fonts = 0;
443 
444 	/* Check that user is only able to set a proper font */
445 	fonts = MagickQueryFonts("*", &num_fonts);
446 
447 	for(i = 0 ; i < num_fonts ; i++) {
448 		/* Let's see if the font is among configured fonts */
449 		if (strncasecmp(fonts[i], font, font_len) == 0) {
450 			retval = 1;
451 			break;
452 		}
453 	}
454 
455 	IMAGICK_FREE_MAGICK_MEMORY(fonts);
456 	return retval;
457 }
458 
php_imagick_file_access_check(const char * filename TSRMLS_DC)459 php_imagick_rw_result_t php_imagick_file_access_check (const char *filename TSRMLS_DC)
460 {
461 	if (strlen(filename) >= MAXPATHLEN)
462 		return IMAGICK_RW_FILENAME_TOO_LONG;
463 
464 #if defined(CHECKUID_CHECK_FILE_AND_DIR)
465 	if (PG(safe_mode) && (!php_checkuid_ex(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR, CHECKUID_NO_ERRORS)))
466 	 	return IMAGICK_RW_SAFE_MODE_ERROR;
467 #endif
468 
469 	if (php_check_open_basedir_ex(filename, 0 TSRMLS_CC))
470 		return IMAGICK_RW_OPEN_BASEDIR_ERROR;
471 
472 	if (VCWD_ACCESS(filename, F_OK) != 0)
473 		return IMAGICK_RW_PATH_DOES_NOT_EXIST;
474 
475 	if (VCWD_ACCESS(filename, R_OK) != 0)
476 		return IMAGICK_RW_PERMISSION_DENIED;
477 
478 	return IMAGICK_RW_OK;
479 }
480 
481 static
s_rw_fail_to_exception(php_imagick_rw_result_t rc,const char * filename TSRMLS_DC)482 void s_rw_fail_to_exception (php_imagick_rw_result_t rc, const char *filename TSRMLS_DC)
483 {
484 	switch (rc) {
485 
486 		case IMAGICK_RW_SAFE_MODE_ERROR:
487 			zend_throw_exception_ex(php_imagick_exception_class_entry, 1 TSRMLS_CC, "Safe mode restricts user to read the file: %s", filename);
488 		break;
489 
490 		case IMAGICK_RW_OPEN_BASEDIR_ERROR:
491 			zend_throw_exception_ex(php_imagick_exception_class_entry, 1 TSRMLS_CC, "open_basedir restriction in effect. File(%s) is not within the allowed path(s)", filename);
492 		break;
493 
494 		case IMAGICK_RW_PERMISSION_DENIED:
495 			zend_throw_exception_ex(php_imagick_exception_class_entry, 1 TSRMLS_CC, "Permission denied to: %s", filename);
496 		break;
497 
498 		case IMAGICK_RW_FILENAME_TOO_LONG:
499 			zend_throw_exception_ex(php_imagick_exception_class_entry, 1 TSRMLS_CC, "Filename too long: %s", filename);
500 		break;
501 
502 		case IMAGICK_RW_PATH_DOES_NOT_EXIST:
503 			zend_throw_exception_ex(php_imagick_exception_class_entry, 1 TSRMLS_CC, "The path does not exist: %s", filename);
504 		break;
505 
506 		case IMAGICK_RW_PATH_IS_DIR:
507 			zend_throw_exception_ex(php_imagick_exception_class_entry, 1 TSRMLS_CC, "The path is a directory: %s", filename);
508 		break;
509 
510 		default:
511 			zend_throw_exception_ex(php_imagick_exception_class_entry, 1 TSRMLS_CC, "Unknown error");
512 		break;
513 	}
514 }
515 
php_imagick_rw_fail_to_exception(MagickWand * magick_wand,php_imagick_rw_result_t rc,const char * filename TSRMLS_DC)516 void php_imagick_rw_fail_to_exception (MagickWand *magick_wand, php_imagick_rw_result_t rc, const char *filename TSRMLS_DC)
517 {
518 	if (rc == IMAGICK_RW_UNDERLYING_LIBRARY) {
519 		php_imagick_convert_imagick_exception (magick_wand, "Failed to read the file" TSRMLS_CC);
520 		return;
521 	}
522 	s_rw_fail_to_exception (rc, filename TSRMLS_CC);
523 }
524 
php_imagick_imagickdraw_rw_fail_to_exception(DrawingWand * drawing_wand,php_imagick_rw_result_t rc,const char * filename TSRMLS_DC)525 void php_imagick_imagickdraw_rw_fail_to_exception (DrawingWand *drawing_wand, php_imagick_rw_result_t rc, const char *filename TSRMLS_DC)
526 {
527 	if (rc == IMAGICK_RW_UNDERLYING_LIBRARY) {
528 		php_imagick_convert_imagickdraw_exception (drawing_wand, "Failed to read the file" TSRMLS_CC);
529 		return;
530 	}
531 	s_rw_fail_to_exception (rc, filename TSRMLS_CC);
532 }
533 
534 
php_imagick_zval_to_pointinfo_array(zval * coordinate_array,int * num_elements TSRMLS_DC)535 PointInfo *php_imagick_zval_to_pointinfo_array(zval *coordinate_array, int *num_elements TSRMLS_DC)
536 {
537 	PointInfo *coordinates;
538 	long elements, sub_elements, i;
539 	HashTable *sub_array;
540 
541 #if PHP_VERSION_ID >= 70000
542 	zval *pzvalue;
543 #else
544 	HashTable *coords;
545 	zval **ppzval;
546 #endif
547 
548 	i = 0;
549 
550 	elements = zend_hash_num_elements(Z_ARRVAL_P(coordinate_array));
551 
552 	if (elements < 1) {
553 		coordinates = (PointInfo *)NULL;
554 		*num_elements = 0;
555 		return coordinates;
556 	}
557 
558 	*num_elements = elements;
559 	coordinates = emalloc(sizeof(PointInfo) * elements);
560 
561 #if PHP_VERSION_ID >= 70000
562 	ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(coordinate_array), pzvalue) {
563 		zval *pz_x, *pz_y;
564 		ZVAL_DEREF(pzvalue);
565 
566 		/* If its something than array lets error here */
567 		if(Z_TYPE_P(pzvalue) != IS_ARRAY) {
568 			efree(coordinates);
569 			*num_elements = 0;
570 			return NULL;
571 		}
572 
573 		/* Subarray should have two elements. X and Y */
574 		sub_elements = zend_hash_num_elements(Z_ARRVAL_P(pzvalue));
575 
576 		/* Exactly two elements */
577 		if (sub_elements != 2) {
578 			efree(coordinates);
579 			*num_elements = 0;
580 			return NULL;
581 		}
582 
583 		/* Subarray values */
584 		sub_array = Z_ARRVAL_P(pzvalue);
585 
586 		/* Get X */
587 		if ((pz_x = zend_hash_str_find(sub_array, "x", sizeof("x")-1)) == NULL) {
588 			efree(coordinates);
589 			*num_elements = 0;
590 			return NULL;
591 		}
592 
593 		/* Get Y */
594 		if ((pz_y = zend_hash_str_find(sub_array, "y", sizeof("y")-1)) == NULL) {
595 			efree(coordinates);
596 			*num_elements = 0;
597 			return NULL;
598 		}
599 
600 		/* Assign X and Y */
601 		coordinates[i].x = zval_get_double(pz_x);
602 		coordinates[i].y = zval_get_double(pz_y);
603 		i++;
604 	} ZEND_HASH_FOREACH_END();
605 
606 #else
607 	coords = Z_ARRVAL_P(coordinate_array);
608 	zend_hash_internal_pointer_reset_ex(coords, (HashPosition *) 0);
609 
610 	for (i = 0, zend_hash_internal_pointer_reset(coords);
611 			zend_hash_get_current_data(coords, (void **) &ppzval) == SUCCESS;
612 			zend_hash_move_forward(coords), i++
613 	) {
614 		zval **ppz_x, **ppz_y;
615 		zval tmp_zx, *tmp_pzx, tmp_zy, *tmp_pzy;
616 
617 		/* If its something than array lets error here */
618 		if(Z_TYPE_PP(ppzval) != IS_ARRAY) {
619 			efree(coordinates);
620 			*num_elements = 0;
621 			return NULL;
622 		}
623 
624 		/* Subarray should have two elements. X and Y */
625 		sub_elements = zend_hash_num_elements(Z_ARRVAL_PP(ppzval));
626 
627 		/* Exactly two elements */
628 		if (sub_elements != 2) {
629 			efree(coordinates);
630 			*num_elements = 0;
631 			return NULL;
632 		}
633 
634 		/* Subarray values */
635 		sub_array = Z_ARRVAL_PP(ppzval);
636 
637 		/* Get X */
638 		if (zend_hash_find(sub_array, "x", sizeof("x"), (void**)&ppz_x) == FAILURE) {
639 			efree(coordinates);
640 			*num_elements = 0;
641 			return NULL;
642 		}
643 
644 		tmp_zx = **ppz_x;
645 		zval_copy_ctor(&tmp_zx);
646 		tmp_pzx = &tmp_zx;
647 		convert_to_double(tmp_pzx);
648 
649 		/* Get Y */
650 		if (zend_hash_find(sub_array, "y", sizeof("y"), (void**)&ppz_y) == FAILURE) {
651 			efree(coordinates);
652 			*num_elements = 0;
653 			return NULL;
654 		}
655 
656 		tmp_zy = **ppz_y;
657 		zval_copy_ctor(&tmp_zy);
658 		tmp_pzy = &tmp_zy;
659 		convert_to_double(tmp_pzy);
660 
661 		/* Assign X and Y */
662 		coordinates[i].x = Z_DVAL(tmp_zx);
663 		coordinates[i].y = Z_DVAL(tmp_zy);
664 	}
665 #endif
666 
667 	return coordinates;
668 }
669 
php_imagick_throw_exception(php_imagick_class_type_t type,const char * description TSRMLS_DC)670 void php_imagick_throw_exception (php_imagick_class_type_t type, const char *description TSRMLS_DC)
671 {
672 	int code;
673 	zend_class_entry *ce = NULL;
674 
675 	switch (type) {
676 		case IMAGICK_CLASS:
677 		default:
678 			ce = php_imagick_exception_class_entry;
679 			code = 1;
680 		break;
681 
682 		case IMAGICKDRAW_CLASS:
683 			ce = php_imagickdraw_exception_class_entry;
684 			code = 2;
685 		break;
686 
687 		case IMAGICKPIXELITERATOR_CLASS:
688 			ce = php_imagickpixeliterator_exception_class_entry;
689 			code = 3;
690 		break;
691 
692 		case IMAGICKPIXEL_CLASS:
693 			ce = php_imagickpixel_exception_class_entry;
694 			code = 4;
695 		break;
696 #ifdef IMAGICK_WITH_KERNEL
697 		case IMAGICKKERNEL_CLASS:
698 			ce = php_imagickkernel_exception_class_entry;
699 			code = 5;
700 		break;
701 #endif
702 	}
703 	zend_throw_exception(ce, description, code TSRMLS_CC);
704 }
705 
706 static
s_convert_exception(char * description,const char * default_message,long severity,int code TSRMLS_DC)707 void s_convert_exception (char *description, const char *default_message, long severity, int code TSRMLS_DC)
708 {
709 	// No description provided or empty one
710 	if (!description || (strlen (description) == 0)) {
711 		if (description) {
712 			description = MagickRelinquishMemory (description);
713 		}
714 		zend_throw_exception(php_imagick_exception_class_entry, default_message, code TSRMLS_CC);
715 		return;
716 	}
717 	zend_throw_exception(php_imagick_exception_class_entry, description, severity TSRMLS_CC);
718 	MagickRelinquishMemory (description);
719 }
720 
721 /**
722 	Convert ImageMagick MagickWand exception to PHP exception
723 */
php_imagick_convert_imagick_exception(MagickWand * magick_wand,const char * default_message TSRMLS_DC)724 void php_imagick_convert_imagick_exception (MagickWand *magick_wand, const char *default_message TSRMLS_DC)
725 {
726 	ExceptionType severity;
727 	char *description;
728 
729 	description = MagickGetException(magick_wand, &severity);
730 	MagickClearException (magick_wand);
731 
732 	s_convert_exception (description, default_message, severity, 1 TSRMLS_CC);
733 }
734 
php_imagick_convert_imagickdraw_exception(DrawingWand * drawing_wand,const char * default_message TSRMLS_DC)735 void php_imagick_convert_imagickdraw_exception (DrawingWand *drawing_wand, const char *default_message TSRMLS_DC)
736 {
737 	ExceptionType severity;
738 	char *description;
739 
740 	description = DrawGetException(drawing_wand, &severity);
741 	DrawClearException (drawing_wand);
742 
743 	s_convert_exception (description, default_message, severity, 2 TSRMLS_CC);
744 }
745 
php_imagick_convert_imagickpixeliterator_exception(PixelIterator * pixel_iterator,const char * default_message TSRMLS_DC)746 void php_imagick_convert_imagickpixeliterator_exception (PixelIterator *pixel_iterator, const char *default_message TSRMLS_DC)
747 {
748 	ExceptionType severity;
749 	char *description;
750 
751 	description = PixelGetIteratorException(pixel_iterator, &severity);
752 	PixelClearIteratorException (pixel_iterator);
753 
754 	s_convert_exception (description, default_message, severity, 3 TSRMLS_CC);
755 }
756 
php_imagick_convert_imagickpixel_exception(PixelWand * pixel_wand,const char * default_message TSRMLS_DC)757 void php_imagick_convert_imagickpixel_exception (PixelWand *pixel_wand, const char *default_message TSRMLS_DC)
758 {
759 	ExceptionType severity;
760 	char *description;
761 
762 	description = PixelGetException(pixel_wand, &severity);
763 	PixelClearException (pixel_wand);
764 
765 	s_convert_exception (description, default_message, severity, 4 TSRMLS_CC);
766 }
767 
php_imagick_zval_to_pixelwand(zval * param,php_imagick_class_type_t caller,zend_bool * allocated TSRMLS_DC)768 PixelWand *php_imagick_zval_to_pixelwand (zval *param, php_imagick_class_type_t caller, zend_bool *allocated TSRMLS_DC)
769 {
770 	PixelWand *pixel_wand = NULL;
771 	*allocated = 0;
772 
773 #if PHP_VERSION_ID >= 70000
774 	ZVAL_DEREF(param);
775 #endif
776 	if (Z_TYPE_P (param) == IS_LONG || Z_TYPE_P (param) == IS_DOUBLE) {
777 		zval var;
778 		var = *param;
779 
780 		zval_copy_ctor(&var);
781 		convert_to_string(&var);
782 		param = &var;
783 	}
784 
785 	switch (Z_TYPE_P(param)) {
786 		case IS_STRING:
787 		{
788 			pixel_wand = NewPixelWand();
789 			if (!pixel_wand) {
790 				zend_error(E_ERROR, "Failed to allocate PixelWand structure");
791 			}
792 			*allocated = 1;
793 
794 			if (PixelSetColor (pixel_wand, Z_STRVAL_P(param)) == MagickFalse) {
795 				pixel_wand = DestroyPixelWand(pixel_wand);
796 				php_imagick_throw_exception (caller, "Unrecognized color string" TSRMLS_CC);
797 				return NULL;
798 			}
799 		}
800 		break;
801 
802 		case IS_OBJECT:
803 			if (instanceof_function(Z_OBJCE_P(param), php_imagickpixel_sc_entry TSRMLS_CC)) {
804 				php_imagickpixel_object *intern = Z_IMAGICKPIXEL_P(param);
805 				pixel_wand = intern->pixel_wand;
806 			} else
807 				php_imagick_throw_exception(caller, "The parameter must be an instance of ImagickPixel or a string" TSRMLS_CC);
808 		break;
809 
810 		default:
811 			php_imagick_throw_exception(caller, "Invalid color parameter provided" TSRMLS_CC);
812 	}
813 	return pixel_wand;
814 }
815 
php_imagick_zval_to_opacity(zval * param,php_imagick_class_type_t caller,zend_bool * allocated TSRMLS_DC)816 PixelWand *php_imagick_zval_to_opacity (zval *param, php_imagick_class_type_t caller, zend_bool *allocated TSRMLS_DC)
817 {
818 	PixelWand *pixel_wand = NULL;
819 	*allocated = 0;
820 
821 #if PHP_VERSION_ID >= 70000
822 	ZVAL_DEREF(param);
823 #endif
824 	if (Z_TYPE_P (param) == IS_STRING) {
825 		zval var;
826 		var = *param;
827 
828 		zval_copy_ctor(&var);
829 		convert_to_double(&var);
830 		param = &var;
831 	}
832 
833 	switch (Z_TYPE_P(param)) {
834 		case IS_LONG:
835 		case IS_DOUBLE:
836 		{
837 			pixel_wand = NewPixelWand();
838 			if (!pixel_wand) {
839 				zend_error(E_ERROR, "Failed to allocate PixelWand structure");
840 			}
841 #if MagickLibVersion >= 0x700
842 			//TOOD - this should be one minus? Or should we just make a BC break
843 			// and make users do it in user land?
844 			PixelSetAlpha(pixel_wand, Z_DVAL_P(param));
845 #else
846 			PixelSetOpacity(pixel_wand, Z_DVAL_P(param));
847 #endif
848 			*allocated = 1;
849 		}
850 		break;
851 
852 		case IS_OBJECT:
853 			if (instanceof_function(Z_OBJCE_P(param), php_imagickpixel_sc_entry TSRMLS_CC)) {
854 				php_imagickpixel_object *intern = Z_IMAGICKPIXEL_P(param);
855 				pixel_wand = intern->pixel_wand;
856 			} else
857 				php_imagick_throw_exception(caller, "The parameter must be an instance of ImagickPixel or a string"  TSRMLS_CC);
858 		break;
859 
860 		default:
861 			php_imagick_throw_exception(caller, "Invalid color parameter provided" TSRMLS_CC);
862 	}
863 	return pixel_wand;
864 }
865 
866 /**
867  * Changes the locale to IMAGICK_LC_NUMERIC_LOCALE if imagick.locale_fix is on
868  * and returns the locale set before calling this function.
869  * If locale is not changed, NULL is returned
870  *
871  */
php_imagick_set_locale(TSRMLS_D)872 char *php_imagick_set_locale (TSRMLS_D)
873 {
874 	char *current_locale;
875 
876 	if (!IMAGICK_G(locale_fix))
877 		return NULL;
878 
879 	current_locale = setlocale(LC_NUMERIC, NULL);
880 	if (current_locale != NULL) {
881 		if (strcmp (current_locale, IMAGICK_LC_NUMERIC_LOCALE) != 0) {
882 			setlocale (LC_NUMERIC, IMAGICK_LC_NUMERIC_LOCALE);
883 			return estrdup (current_locale);
884 		}
885 	}
886 	return NULL;
887 }
888 
php_imagick_restore_locale(const char * old_locale)889 void php_imagick_restore_locale (const char *old_locale)
890 {
891 	if (!old_locale)
892 		return;
893 
894 	if (strcmp (old_locale, IMAGICK_LC_NUMERIC_LOCALE) != 0)
895 		setlocale (LC_NUMERIC, old_locale);
896 }
897 
php_imagick_clone_pixelwand(PixelWand * source)898 PixelWand *php_imagick_clone_pixelwand (PixelWand *source)
899 {
900 #if MagickLibVersion >= 0x635
901 	return ClonePixelWand(source);
902 #else
903 	PixelWand *target = NewPixelWand ();
904 	if (!target)
905 		return NULL;
906 
907 	PixelSetColorCount (target, PixelGetColorCount (source));
908 	PixelSetRed (target, PixelGetRed (source));
909 	PixelSetGreen (target, PixelGetGreen (source));
910 	PixelSetBlue (target, PixelGetBlue (source));
911 	PixelSetOpacity (target, PixelGetOpacity (source));
912 	PixelSetAlpha (target, PixelGetAlpha (source));
913 
914 	return target;
915 #endif
916 }
917 
php_imagick_replace_magickwand(php_imagick_object * obj,MagickWand * new_wand)918 void php_imagick_replace_magickwand (php_imagick_object *obj, MagickWand *new_wand)
919 {
920 	if (!obj->magick_wand)
921 		obj->magick_wand = new_wand;
922 	else {
923 		obj->magick_wand = DestroyMagickWand(obj->magick_wand);
924 		obj->magick_wand = new_wand;
925 	}
926 }
927 
php_imagick_replace_drawingwand(php_imagickdraw_object * obj,DrawingWand * new_wand)928 void php_imagick_replace_drawingwand (php_imagickdraw_object *obj, DrawingWand *new_wand)
929 {
930 	if (!obj->drawing_wand)
931 		obj->drawing_wand = new_wand;
932 	else {
933 		obj->drawing_wand = DestroyDrawingWand(obj->drawing_wand);
934 		obj->drawing_wand = new_wand;
935 	}
936 }
937 
php_imagick_replace_pixelwand(php_imagickpixel_object * obj,PixelWand * new_wand)938 void php_imagick_replace_pixelwand (php_imagickpixel_object *obj, PixelWand *new_wand)
939 {
940 	if (obj->pixel_wand && obj->initialized_via_iterator != 1) {
941 		obj->pixel_wand = DestroyPixelWand(obj->pixel_wand);
942 		obj->pixel_wand = new_wand;
943 	} else
944 		obj->pixel_wand = new_wand;
945 }
946 
php_imagick_ensure_not_empty(MagickWand * magick_wand)947 zend_bool php_imagick_ensure_not_empty (MagickWand *magick_wand)
948 {
949 	if (MagickGetNumberImages(magick_wand) == 0) {
950 		TSRMLS_FETCH ();
951 		php_imagick_throw_exception (IMAGICK_CLASS, "Can not process empty Imagick object" TSRMLS_CC);
952 		return 0;
953 	}
954 	return 1;
955 }
956 
php_imagickpixel_ensure_not_null(PixelWand * pixel_wand)957 zend_bool php_imagickpixel_ensure_not_null(PixelWand *pixel_wand)
958 {
959 	if (pixel_wand == NULL) {
960 		TSRMLS_FETCH ();
961 		php_imagick_throw_exception (IMAGICKPIXEL_CLASS, "Can not process empty ImagickPixel object" TSRMLS_CC);
962 		return 0;
963 	}
964 	return 1;
965 }
966 
php_imagick_initialize_constants(TSRMLS_D)967 void php_imagick_initialize_constants(TSRMLS_D)
968 {
969 #define IMAGICK_REGISTER_CONST_LONG(const_name, value)\
970 	zend_declare_class_constant_long(php_imagick_sc_entry, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC);
971 
972 #define IMAGICK_REGISTER_CONST_STRING(const_name, value)\
973 	zend_declare_class_constant_string(php_imagick_sc_entry, const_name, sizeof(const_name)-1, value TSRMLS_CC);
974 
975 	/* Constants defined in php_imagick.h */
976 	IMAGICK_REGISTER_CONST_LONG("COLOR_BLACK", PHP_IMAGICK_COLOR_BLACK);
977 	IMAGICK_REGISTER_CONST_LONG("COLOR_BLUE", PHP_IMAGICK_COLOR_BLUE);
978 	IMAGICK_REGISTER_CONST_LONG("COLOR_CYAN", PHP_IMAGICK_COLOR_CYAN);
979 	IMAGICK_REGISTER_CONST_LONG("COLOR_GREEN", PHP_IMAGICK_COLOR_GREEN);
980 	IMAGICK_REGISTER_CONST_LONG("COLOR_RED", PHP_IMAGICK_COLOR_RED);
981 	IMAGICK_REGISTER_CONST_LONG("COLOR_YELLOW", PHP_IMAGICK_COLOR_YELLOW);
982 	IMAGICK_REGISTER_CONST_LONG("COLOR_MAGENTA", PHP_IMAGICK_COLOR_MAGENTA);
983 #if MagickLibVersion < 0x700
984 	IMAGICK_REGISTER_CONST_LONG("COLOR_OPACITY", PHP_IMAGICK_COLOR_OPACITY);
985 #endif
986 	IMAGICK_REGISTER_CONST_LONG("COLOR_ALPHA", PHP_IMAGICK_COLOR_ALPHA);
987 	IMAGICK_REGISTER_CONST_LONG("COLOR_FUZZ", PHP_IMAGICK_COLOR_FUZZ);
988 
989 	/* Returning the version as a constant string */
990 	IMAGICK_REGISTER_CONST_LONG("IMAGICK_EXTNUM", PHP_IMAGICK_EXTNUM);
991 	IMAGICK_REGISTER_CONST_STRING("IMAGICK_EXTVER", PHP_IMAGICK_VERSION);
992 
993 #if defined(MagickQuantumRange)
994 	IMAGICK_REGISTER_CONST_LONG("QUANTUM_RANGE", atoi (MagickQuantumRange));
995 #endif
996 
997 	/* Are we using PHP allocations */
998 #ifdef PHP_IMAGICK_ZEND_MM
999 	IMAGICK_REGISTER_CONST_LONG("USE_ZEND_MM", 1);
1000 #else
1001 	IMAGICK_REGISTER_CONST_LONG("USE_ZEND_MM", 0);
1002 #endif
1003 
1004 	/* ImageMagick defined constants */
1005 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_DEFAULT", OverCompositeOp);
1006 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_UNDEFINED", UndefinedCompositeOp);
1007 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_NO", NoCompositeOp);
1008 #if MagickLibVersion < 0x700
1009 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_ADD", AddCompositeOp);
1010 #endif
1011 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_ATOP", AtopCompositeOp);
1012 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_BLEND", BlendCompositeOp);
1013 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_BUMPMAP", BumpmapCompositeOp);
1014 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_CLEAR", ClearCompositeOp);
1015 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_COLORBURN", ColorBurnCompositeOp);
1016 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_COLORDODGE", ColorDodgeCompositeOp);
1017 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_COLORIZE", ColorizeCompositeOp);
1018 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_COPYBLACK", CopyBlackCompositeOp);
1019 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_COPYBLUE", CopyBlueCompositeOp);
1020 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_COPY", CopyCompositeOp);
1021 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_COPYCYAN", CopyCyanCompositeOp);
1022 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_COPYGREEN", CopyGreenCompositeOp);
1023 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_COPYMAGENTA", CopyMagentaCompositeOp);
1024 #if MagickLibVersion >= 0x700
1025 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_COPYALPHA", CopyAlphaCompositeOp);
1026 	//TOOD - is this semantically correct?
1027 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_COPYOPACITY", CopyAlphaCompositeOp);
1028 #else
1029 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_COPYOPACITY", CopyOpacityCompositeOp);
1030 #endif
1031 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_COPYRED", CopyRedCompositeOp);
1032 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_COPYYELLOW", CopyYellowCompositeOp);
1033 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_DARKEN", DarkenCompositeOp);
1034 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_DSTATOP", DstAtopCompositeOp);
1035 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_DST", DstCompositeOp);
1036 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_DSTIN", DstInCompositeOp);
1037 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_DSTOUT", DstOutCompositeOp);
1038 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_DSTOVER", DstOverCompositeOp);
1039 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_DIFFERENCE", DifferenceCompositeOp);
1040 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_DISPLACE", DisplaceCompositeOp);
1041 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_DISSOLVE", DissolveCompositeOp);
1042 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_EXCLUSION", ExclusionCompositeOp);
1043 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_HARDLIGHT", HardLightCompositeOp);
1044 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_HUE", HueCompositeOp);
1045 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_IN", InCompositeOp);
1046 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_LIGHTEN", LightenCompositeOp);
1047 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_LUMINIZE", LuminizeCompositeOp);
1048 #if MagickLibVersion < 0x700
1049 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_MINUS", MinusCompositeOp);
1050 #endif
1051 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_MODULATE", ModulateCompositeOp);
1052 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_MULTIPLY", MultiplyCompositeOp);
1053 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_OUT", OutCompositeOp);
1054 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_OVER", OverCompositeOp);
1055 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_OVERLAY", OverlayCompositeOp);
1056 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_PLUS", PlusCompositeOp);
1057 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_REPLACE", ReplaceCompositeOp);
1058 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_SATURATE", SaturateCompositeOp);
1059 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_SCREEN", ScreenCompositeOp);
1060 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_SOFTLIGHT", SoftLightCompositeOp);
1061 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_SRCATOP", SrcAtopCompositeOp);
1062 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_SRC", SrcCompositeOp);
1063 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_SRCIN", SrcInCompositeOp);
1064 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_SRCOUT", SrcOutCompositeOp);
1065 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_SRCOVER", SrcOverCompositeOp);
1066 #if MagickLibVersion < 0x700
1067 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_SUBTRACT", SubtractCompositeOp);
1068 #endif
1069 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_THRESHOLD", ThresholdCompositeOp);
1070 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_XOR", XorCompositeOp);
1071 #if MagickLibVersion >= 0x634
1072 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_CHANGEMASK", ChangeMaskCompositeOp);
1073 #endif
1074 #if MagickLibVersion >= 0x636
1075 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_LINEARLIGHT", LinearLightCompositeOp);
1076 #if MagickLibVersion < 0x700
1077 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_DIVIDE", DivideCompositeOp);
1078 #endif
1079 #endif
1080 #if MagickLibVersion >= 0x654
1081 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_DISTORT", DistortCompositeOp);
1082 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_BLUR", BlurCompositeOp);
1083 #endif
1084 #if MagickLibVersion >= 0x655
1085 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_PEGTOPLIGHT", PegtopLightCompositeOp);
1086 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_VIVIDLIGHT", VividLightCompositeOp);
1087 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_PINLIGHT", PinLightCompositeOp);
1088 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_LINEARDODGE", LinearDodgeCompositeOp);
1089 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_LINEARBURN", LinearBurnCompositeOp);
1090 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_MATHEMATICS", MathematicsCompositeOp);
1091 #endif
1092 #if MagickLibVersion >= 0x662
1093 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_MODULUSADD", ModulusAddCompositeOp);
1094 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_MODULUSSUBTRACT", ModulusSubtractCompositeOp);
1095 #endif
1096 #if MagickLibVersion >= 0x670
1097 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_MINUSDST", MinusDstCompositeOp);
1098 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_DIVIDEDST", DivideDstCompositeOp);
1099 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_DIVIDESRC", DivideSrcCompositeOp);
1100 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_MINUSSRC", MinusSrcCompositeOp);
1101 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_DARKENINTENSITY", DarkenIntensityCompositeOp);
1102 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_LIGHTENINTENSITY", LightenIntensityCompositeOp);
1103 #endif
1104 #if MagickLibVersion >= 0x690
1105 	IMAGICK_REGISTER_CONST_LONG("COMPOSITE_HARDMIX", HardMixCompositeOp);
1106 #endif
1107 
1108 #if (MagickLibVersion >= 0x700 && MagickLibVersion >= 0x708) || (MagickLibVersion < 0x700 && MagickLibVersion >= 0x69A)
1109     IMAGICK_REGISTER_CONST_LONG("COMPOSITE_STEREO", StereoCompositeOp);
1110 #endif
1111 
1112 #if MagickLibVersion >= 0x70A
1113     IMAGICK_REGISTER_CONST_LONG("COMPOSITE_FREEZE", FreezeCompositeOp);
1114     IMAGICK_REGISTER_CONST_LONG("COMPOSITE_INTERPOLATE", InterpolateCompositeOp);
1115     IMAGICK_REGISTER_CONST_LONG("COMPOSITE_NEGATE", NegateCompositeOp);
1116     IMAGICK_REGISTER_CONST_LONG("COMPOSITE_REFLECT", ReflectCompositeOp);
1117     IMAGICK_REGISTER_CONST_LONG("COMPOSITE_SOFTBURN", SoftBurnCompositeOp);
1118     IMAGICK_REGISTER_CONST_LONG("COMPOSITE_SOFTDODGE", SoftDodgeCompositeOp);
1119     IMAGICK_REGISTER_CONST_LONG("COMPOSITE_STAMP", StampCompositeOp);
1120 #endif
1121 
1122 #if MagickLibVersion >= 0x70B
1123     IMAGICK_REGISTER_CONST_LONG("COMPOSITE_RMSE", RMSECompositeOp);
1124 #endif
1125 
1126 	IMAGICK_REGISTER_CONST_LONG("MONTAGEMODE_FRAME", FrameMode);
1127 	IMAGICK_REGISTER_CONST_LONG("MONTAGEMODE_UNFRAME", UnframeMode);
1128 	IMAGICK_REGISTER_CONST_LONG("MONTAGEMODE_CONCATENATE", ConcatenateMode);
1129 	IMAGICK_REGISTER_CONST_LONG("STYLE_NORMAL", NormalStyle);
1130 	IMAGICK_REGISTER_CONST_LONG("STYLE_ITALIC", ItalicStyle);
1131 	IMAGICK_REGISTER_CONST_LONG("STYLE_OBLIQUE", ObliqueStyle);
1132 	IMAGICK_REGISTER_CONST_LONG("STYLE_ANY", AnyStyle);
1133 #if (MagickLibVersion >= 0x700 && MagickLibVersion >= 0x709) || (MagickLibVersion < 0x700 && MagickLibVersion >= 0x69B)
1134     IMAGICK_REGISTER_CONST_LONG("STYLE_BOLD", BoldStyle);
1135 #endif
1136 
1137 	IMAGICK_REGISTER_CONST_LONG("FILTER_UNDEFINED", UndefinedFilter);
1138 	IMAGICK_REGISTER_CONST_LONG("FILTER_POINT", PointFilter);
1139 	IMAGICK_REGISTER_CONST_LONG("FILTER_BOX", BoxFilter);
1140 	IMAGICK_REGISTER_CONST_LONG("FILTER_TRIANGLE", TriangleFilter);
1141 	IMAGICK_REGISTER_CONST_LONG("FILTER_HERMITE", HermiteFilter);
1142 #if MagickLibVersion >= 0x701
1143 	IMAGICK_REGISTER_CONST_LONG("FILTER_HANNING", HannFilter);
1144 	IMAGICK_REGISTER_CONST_LONG("FILTER_HANN", HannFilter);
1145 #else
1146 	IMAGICK_REGISTER_CONST_LONG("FILTER_HANNING", HanningFilter);
1147 #endif
1148 	IMAGICK_REGISTER_CONST_LONG("FILTER_HAMMING", HammingFilter);
1149 	IMAGICK_REGISTER_CONST_LONG("FILTER_BLACKMAN", BlackmanFilter);
1150 	IMAGICK_REGISTER_CONST_LONG("FILTER_GAUSSIAN", GaussianFilter);
1151 	IMAGICK_REGISTER_CONST_LONG("FILTER_QUADRATIC", QuadraticFilter);
1152 	IMAGICK_REGISTER_CONST_LONG("FILTER_CUBIC", CubicFilter);
1153 	IMAGICK_REGISTER_CONST_LONG("FILTER_CATROM", CatromFilter);
1154 	IMAGICK_REGISTER_CONST_LONG("FILTER_MITCHELL", MitchellFilter);
1155 	IMAGICK_REGISTER_CONST_LONG("FILTER_LANCZOS", LanczosFilter);
1156 	IMAGICK_REGISTER_CONST_LONG("FILTER_BESSEL", BesselFilter);
1157 	IMAGICK_REGISTER_CONST_LONG("FILTER_SINC", SincFilter);
1158 #if MagickLibVersion >= 0x637
1159 	IMAGICK_REGISTER_CONST_LONG("FILTER_KAISER", KaiserFilter);
1160 #if MagickLibVersion >= 0x701
1161 	IMAGICK_REGISTER_CONST_LONG("FILTER_WELSH", WelshFilter);
1162 	IMAGICK_REGISTER_CONST_LONG("FILTER_WELCH", WelchFilter);
1163 #else
1164 	IMAGICK_REGISTER_CONST_LONG("FILTER_WELSH", WelshFilter);
1165 #endif
1166 	IMAGICK_REGISTER_CONST_LONG("FILTER_PARZEN", ParzenFilter);
1167 	IMAGICK_REGISTER_CONST_LONG("FILTER_LAGRANGE", LagrangeFilter);
1168 	IMAGICK_REGISTER_CONST_LONG("FILTER_SENTINEL", SentinelFilter);
1169 #endif
1170 #if MagickLibVersion >= 0x638
1171 	IMAGICK_REGISTER_CONST_LONG("FILTER_BOHMAN", BohmanFilter);
1172 	IMAGICK_REGISTER_CONST_LONG("FILTER_BARTLETT", BartlettFilter);
1173 #endif
1174 #if MagickLibVersion >= 0x666
1175 	IMAGICK_REGISTER_CONST_LONG("FILTER_JINC", JincFilter);
1176 	IMAGICK_REGISTER_CONST_LONG("FILTER_SINCFAST", SincFastFilter);
1177 	IMAGICK_REGISTER_CONST_LONG("FILTER_ROBIDOUX", RobidouxFilter);
1178 	IMAGICK_REGISTER_CONST_LONG("FILTER_LANCZOSSHARP", LanczosSharpFilter);
1179 	IMAGICK_REGISTER_CONST_LONG("FILTER_LANCZOS2", Lanczos2Filter);
1180 	IMAGICK_REGISTER_CONST_LONG("FILTER_LANCZOS2SHARP", Lanczos2SharpFilter);
1181 #endif
1182 #if MagickLibVersion >= 0x677
1183 	IMAGICK_REGISTER_CONST_LONG("FILTER_ROBIDOUXSHARP", RobidouxSharpFilter);
1184 	IMAGICK_REGISTER_CONST_LONG("FILTER_COSINE", CosineFilter);
1185 #endif
1186 #if MagickLibVersion >= 0x678
1187 	IMAGICK_REGISTER_CONST_LONG("FILTER_SPLINE", SplineFilter);
1188 #endif
1189 #if MagickLibVersion >= 0x681
1190 	IMAGICK_REGISTER_CONST_LONG("FILTER_LANCZOSRADIUS", LanczosRadiusFilter);
1191 #endif
1192 #if MagickLibVersion >= 0x707
1193 	IMAGICK_REGISTER_CONST_LONG("FILTER_CUBIC_SPLINE", CubicSplineFilter);
1194 #endif
1195 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_UNDEFINED", UndefinedType);
1196 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_BILEVEL", BilevelType);
1197 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_GRAYSCALE", GrayscaleType);
1198 #if MagickLibVersion < 0x700
1199 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_GRAYSCALEMATTE", GrayscaleMatteType);
1200 #else
1201 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_GRAYSCALEALPHA", GrayscaleAlphaType);
1202 	//@TODO - this is only here for legacy support
1203 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_GRAYSCALEMATTE", GrayscaleAlphaType);
1204 #endif
1205 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_PALETTE",  PaletteType);
1206 #if MagickLibVersion < 0x700
1207 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_PALETTEMATTE", PaletteMatteType);
1208 #else
1209 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_PALETTEMATTE", PaletteAlphaType);
1210 	//@TODO - this is only here for legacy support
1211 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_PALETTEALPHA", PaletteAlphaType);
1212 #endif
1213 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_TRUECOLOR", TrueColorType);
1214 #if MagickLibVersion < 0x700
1215 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_TRUECOLORMATTE", TrueColorMatteType);
1216 #else
1217 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_TRUECOLORALPHA", TrueColorAlphaType);
1218 	//@TODO - this is only here for legacy support
1219 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_TRUECOLORMATTE", TrueColorAlphaType);
1220 
1221 #endif
1222 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_COLORSEPARATION", ColorSeparationType);
1223 #if MagickLibVersion < 0x700
1224 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_COLORSEPARATIONMATTE", ColorSeparationMatteType);
1225 #else
1226 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_COLORSEPARATIONALPHA", ColorSeparationAlphaType);
1227 	//@TODO - this is only here for legacy support
1228 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_COLORSEPARATIONMATTE", ColorSeparationAlphaType);
1229 #endif
1230 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_OPTIMIZE", OptimizeType);
1231 #if MagickLibVersion < 0x700
1232 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_PALETTEBILEVELMATTE", PaletteBilevelMatteType);
1233 #else
1234 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_PALETTEBILEVELALPHA", PaletteBilevelAlphaType);
1235 	//@TODO - this is only here for legacy support
1236 	IMAGICK_REGISTER_CONST_LONG("IMGTYPE_PALETTEBILEVELMATTE", PaletteBilevelAlphaType);
1237 #endif
1238 	IMAGICK_REGISTER_CONST_LONG("RESOLUTION_UNDEFINED", UndefinedResolution);
1239 	IMAGICK_REGISTER_CONST_LONG("RESOLUTION_PIXELSPERINCH", PixelsPerInchResolution);
1240 	IMAGICK_REGISTER_CONST_LONG("RESOLUTION_PIXELSPERCENTIMETER", PixelsPerCentimeterResolution);
1241 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_UNDEFINED", UndefinedCompression);
1242 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_NO", NoCompression);
1243 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_BZIP", BZipCompression);
1244 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_FAX", FaxCompression);
1245 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_GROUP4", Group4Compression);
1246 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_JPEG", JPEGCompression);
1247 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_JPEG2000", JPEG2000Compression);
1248 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_LOSSLESSJPEG", LosslessJPEGCompression);
1249 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_LZW", LZWCompression);
1250 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_RLE", RLECompression);
1251 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_ZIP", ZipCompression);
1252 #if MagickLibVersion > 0x639
1253 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_DXT1", DXT1Compression);
1254 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_DXT3", DXT3Compression);
1255 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_DXT5", DXT5Compression);
1256 #endif
1257 #if MagickLibVersion >= 0x656
1258 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_ZIPS", ZipSCompression);
1259 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_PIZ", PizCompression);
1260 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_PXR24", Pxr24Compression);
1261 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_B44", B44Compression);
1262 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_B44A", B44ACompression);
1263 #endif
1264 #if MagickLibVersion >= 0x667
1265 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_LZMA", LZMACompression);
1266 #endif
1267 #if MagickLibVersion >= 0x670
1268 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_JBIG1", JBIG1Compression);
1269 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_JBIG2", JBIG2Compression);
1270 #endif
1271 
1272 #if MagickLibVersion >= 0x709
1273 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_ZSTD", ZstdCompression);
1274 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_WEBP", WebPCompression);
1275 #endif
1276 
1277 #if MagickLibVersion >= 0x70C
1278 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_DWAA", DWAACompression);
1279 	IMAGICK_REGISTER_CONST_LONG("COMPRESSION_DWAB", DWABCompression);
1280 #endif
1281 
1282 	IMAGICK_REGISTER_CONST_LONG("PAINT_POINT", PointMethod);
1283 	IMAGICK_REGISTER_CONST_LONG("PAINT_REPLACE", ReplaceMethod);
1284 	IMAGICK_REGISTER_CONST_LONG("PAINT_FLOODFILL", FloodfillMethod);
1285 	IMAGICK_REGISTER_CONST_LONG("PAINT_FILLTOBORDER", FillToBorderMethod);
1286 	IMAGICK_REGISTER_CONST_LONG("PAINT_RESET", ResetMethod);
1287 	IMAGICK_REGISTER_CONST_LONG("GRAVITY_NORTHWEST", NorthWestGravity);
1288 	IMAGICK_REGISTER_CONST_LONG("GRAVITY_NORTH", NorthGravity);
1289 	IMAGICK_REGISTER_CONST_LONG("GRAVITY_NORTHEAST", NorthEastGravity);
1290 	IMAGICK_REGISTER_CONST_LONG("GRAVITY_WEST", WestGravity);
1291 	IMAGICK_REGISTER_CONST_LONG("GRAVITY_CENTER", CenterGravity);
1292 	IMAGICK_REGISTER_CONST_LONG("GRAVITY_EAST", EastGravity);
1293 	IMAGICK_REGISTER_CONST_LONG("GRAVITY_SOUTHWEST", SouthWestGravity);
1294 	IMAGICK_REGISTER_CONST_LONG("GRAVITY_SOUTH", SouthGravity);
1295 	IMAGICK_REGISTER_CONST_LONG("GRAVITY_SOUTHEAST", SouthEastGravity);
1296 	IMAGICK_REGISTER_CONST_LONG("GRAVITY_FORGET", ForgetGravity);
1297 #if MagickLibVersion < 0x700
1298 	IMAGICK_REGISTER_CONST_LONG("GRAVITY_STATIC", StaticGravity);
1299 #endif
1300 
1301 	IMAGICK_REGISTER_CONST_LONG("STRETCH_NORMAL", NormalStretch);
1302 	IMAGICK_REGISTER_CONST_LONG("STRETCH_ULTRACONDENSED", UltraCondensedStretch);
1303 	IMAGICK_REGISTER_CONST_LONG("STRETCH_EXTRACONDENSED", ExtraCondensedStretch);
1304 	IMAGICK_REGISTER_CONST_LONG("STRETCH_CONDENSED", CondensedStretch);
1305 	IMAGICK_REGISTER_CONST_LONG("STRETCH_SEMICONDENSED", SemiCondensedStretch);
1306 	IMAGICK_REGISTER_CONST_LONG("STRETCH_SEMIEXPANDED", SemiExpandedStretch);
1307 	IMAGICK_REGISTER_CONST_LONG("STRETCH_EXPANDED", ExpandedStretch);
1308 	IMAGICK_REGISTER_CONST_LONG("STRETCH_EXTRAEXPANDED", ExtraExpandedStretch);
1309 	IMAGICK_REGISTER_CONST_LONG("STRETCH_ULTRAEXPANDED", UltraExpandedStretch);
1310 	IMAGICK_REGISTER_CONST_LONG("STRETCH_ANY", AnyStretch);
1311 	IMAGICK_REGISTER_CONST_LONG("ALIGN_UNDEFINED", UndefinedAlign);
1312 	IMAGICK_REGISTER_CONST_LONG("ALIGN_LEFT", LeftAlign);
1313 	IMAGICK_REGISTER_CONST_LONG("ALIGN_CENTER", CenterAlign);
1314 	IMAGICK_REGISTER_CONST_LONG("ALIGN_RIGHT",	RightAlign);
1315 	IMAGICK_REGISTER_CONST_LONG("DECORATION_NO", NoDecoration);
1316 	IMAGICK_REGISTER_CONST_LONG("DECORATION_UNDERLINE", UnderlineDecoration);
1317 	IMAGICK_REGISTER_CONST_LONG("DECORATION_OVERLINE", OverlineDecoration);
1318 	IMAGICK_REGISTER_CONST_LONG("DECORATION_LINETROUGH", LineThroughDecoration); //TODO remove?
1319 	IMAGICK_REGISTER_CONST_LONG("DECORATION_LINETHROUGH", LineThroughDecoration);
1320 	IMAGICK_REGISTER_CONST_LONG("NOISE_UNIFORM", UniformNoise);
1321 	IMAGICK_REGISTER_CONST_LONG("NOISE_GAUSSIAN", GaussianNoise);
1322 	IMAGICK_REGISTER_CONST_LONG("NOISE_MULTIPLICATIVEGAUSSIAN", MultiplicativeGaussianNoise);
1323 	IMAGICK_REGISTER_CONST_LONG("NOISE_IMPULSE", ImpulseNoise);
1324 	IMAGICK_REGISTER_CONST_LONG("NOISE_LAPLACIAN", LaplacianNoise);
1325 	IMAGICK_REGISTER_CONST_LONG("NOISE_POISSON", PoissonNoise);
1326 #if MagickLibVersion > 0x635
1327 	IMAGICK_REGISTER_CONST_LONG("NOISE_RANDOM", RandomNoise);
1328 #endif
1329 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_UNDEFINED", UndefinedChannel);
1330 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_RED", RedChannel);
1331 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_GRAY", GrayChannel);
1332 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_CYAN", CyanChannel);
1333 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_GREEN", GreenChannel);
1334 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_MAGENTA", MagentaChannel);
1335 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_BLUE", BlueChannel);
1336 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_YELLOW", YellowChannel);
1337 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_ALPHA", AlphaChannel);
1338 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_OPACITY", OpacityChannel);
1339 #if MagickLibVersion < 0x700
1340 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_MATTE", MatteChannel); /* deprecated, needs to throw E_STRICT if used */
1341 #endif
1342 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_BLACK", BlackChannel);
1343 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_INDEX", IndexChannel);
1344 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_ALL", AllChannels);
1345 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_DEFAULT", DefaultChannels);
1346 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_RGBA", RedChannel | GreenChannel | BlueChannel | AlphaChannel);
1347 #if MagickLibVersion >= 0x644
1348 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_TRUEALPHA", TrueAlphaChannel);
1349 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_RGBS", RGBChannels);
1350 #endif
1351 #if MagickLibVersion >= 0x655
1352 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_GRAY_CHANNELS", GrayChannels);
1353 #endif
1354 #if MagickLibVersion >= 0x656
1355 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_SYNC", SyncChannels);
1356 #endif
1357 
1358 #if MagickLibVersion >= 0x700
1359 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_READ_MASK", ReadMaskChannel);          /* Pixel is Not Readable? */
1360 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_WRITE_MASK", WriteMaskChannel);         /* Pixel is Write Protected? */
1361 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_META", MetaChannel);              /* ???? */
1362 #endif
1363 
1364 #if MagickLibVersion >= 0x708
1365 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_COMPOSITE_MASK", CompositeMaskChannel);              /* SVG mask */
1366 #endif
1367 
1368 #if MagickLibVersion >= 0x670
1369 	IMAGICK_REGISTER_CONST_LONG("CHANNEL_COMPOSITES", CompositeChannels);
1370 #endif
1371 #if MagickLibVersion < 0x700
1372 	IMAGICK_REGISTER_CONST_LONG("METRIC_UNDEFINED", UndefinedMetric);
1373 #endif
1374 	IMAGICK_REGISTER_CONST_LONG("METRIC_ABSOLUTEERRORMETRIC", AbsoluteErrorMetric);
1375 	IMAGICK_REGISTER_CONST_LONG("METRIC_MEANABSOLUTEERROR", MeanAbsoluteErrorMetric);
1376 #if MagickLibVersion < 0x700
1377 	IMAGICK_REGISTER_CONST_LONG("METRIC_MEANERRORPERPIXELMETRIC", MeanErrorPerPixelMetric);
1378 #else
1379 	IMAGICK_REGISTER_CONST_LONG("METRIC_MEANERRORPERPIXELMETRIC", MeanErrorPerPixelErrorMetric);
1380 #endif
1381 
1382 	IMAGICK_REGISTER_CONST_LONG("METRIC_MEANSQUAREERROR", MeanSquaredErrorMetric);
1383 	IMAGICK_REGISTER_CONST_LONG("METRIC_PEAKABSOLUTEERROR", PeakAbsoluteErrorMetric);
1384 #if MagickLibVersion < 0x700
1385 	IMAGICK_REGISTER_CONST_LONG("METRIC_PEAKSIGNALTONOISERATIO", PeakSignalToNoiseRatioMetric);
1386 #else
1387 	IMAGICK_REGISTER_CONST_LONG("METRIC_PEAKSIGNALTONOISERATIO", PeakSignalToNoiseRatioErrorMetric);
1388 #endif
1389 	IMAGICK_REGISTER_CONST_LONG("METRIC_ROOTMEANSQUAREDERROR", RootMeanSquaredErrorMetric);
1390 #if MagickLibVersion >= 0x687
1391 	IMAGICK_REGISTER_CONST_LONG("METRIC_NORMALIZEDCROSSCORRELATIONERRORMETRIC", NormalizedCrossCorrelationErrorMetric);
1392 	IMAGICK_REGISTER_CONST_LONG("METRIC_FUZZERROR", FuzzErrorMetric);
1393 #endif
1394 #if MagickLibVersion >= 0x690
1395 	IMAGICK_REGISTER_CONST_LONG("METRIC_PERCEPTUALHASH_ERROR", PerceptualHashErrorMetric);
1396 #endif
1397 
1398 #if MagickLibVersion >= 0x707
1399 	IMAGICK_REGISTER_CONST_LONG("METRIC_STRUCTURAL_SIMILARITY_ERROR", StructuralSimilarityErrorMetric);
1400 	IMAGICK_REGISTER_CONST_LONG("METRIC_STRUCTURAL_DISSIMILARITY_ERROR", StructuralDissimilarityErrorMetric);
1401 #endif
1402 
1403 	IMAGICK_REGISTER_CONST_LONG("PIXEL_CHAR", CharPixel);
1404 	IMAGICK_REGISTER_CONST_LONG("PIXELSTORAGE_CHAR", CharPixel);
1405 	IMAGICK_REGISTER_CONST_LONG("PIXEL_DOUBLE", DoublePixel);
1406 	IMAGICK_REGISTER_CONST_LONG("PIXELSTORAGE_DOUBLE", DoublePixel);
1407 	IMAGICK_REGISTER_CONST_LONG("PIXEL_FLOAT", FloatPixel);
1408 	IMAGICK_REGISTER_CONST_LONG("PIXELSTORAGE_FLOAT", FloatPixel);
1409 #if MagickLibVersion < 0x700
1410 	IMAGICK_REGISTER_CONST_LONG("PIXEL_INTEGER", IntegerPixel);
1411 	IMAGICK_REGISTER_CONST_LONG("PIXELSTORAGE_INTEGER", IntegerPixel);
1412 #endif
1413 	IMAGICK_REGISTER_CONST_LONG("PIXEL_LONG", LongPixel);
1414 	IMAGICK_REGISTER_CONST_LONG("PIXELSTORAGE_LONG", LongPixel);
1415 	IMAGICK_REGISTER_CONST_LONG("PIXEL_QUANTUM", QuantumPixel);
1416 	IMAGICK_REGISTER_CONST_LONG("PIXELSTORAGE_QUANTUM", QuantumPixel);
1417 	IMAGICK_REGISTER_CONST_LONG("PIXEL_SHORT", ShortPixel);
1418 	IMAGICK_REGISTER_CONST_LONG("PIXELSTORAGE_SHORT", ShortPixel);
1419 	//For now we deliberately DO NOT support the longlong pixel type.
1420 	//64 bit integers and PHP do not play nicely.
1421 	//IMAGICK_REGISTER_CONST_LONG("PIXEL_LONGLONG", ..);
1422 	//IMAGICK_REGISTER_CONST_LONG("PIXELSTORAGE_LONGLONG", ..);
1423 
1424 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_UNDEFINED", UndefinedEvaluateOperator);
1425 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_ADD", AddEvaluateOperator);
1426 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_AND", AndEvaluateOperator);
1427 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_DIVIDE", DivideEvaluateOperator);
1428 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_LEFTSHIFT", LeftShiftEvaluateOperator);
1429 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_MAX", MaxEvaluateOperator);
1430 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_MIN", MinEvaluateOperator);
1431 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_MULTIPLY", MultiplyEvaluateOperator);
1432 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_OR", OrEvaluateOperator);
1433 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_RIGHTSHIFT", RightShiftEvaluateOperator);
1434 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_SET", SetEvaluateOperator);
1435 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_SUBTRACT", SubtractEvaluateOperator);
1436 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_XOR", XorEvaluateOperator);
1437 #if MagickLibVersion > 0x643
1438 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_POW", PowEvaluateOperator);
1439 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_LOG", LogEvaluateOperator);
1440 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_THRESHOLD", ThresholdEvaluateOperator);
1441 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_THRESHOLDBLACK", ThresholdBlackEvaluateOperator);
1442 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_THRESHOLDWHITE", ThresholdWhiteEvaluateOperator);
1443 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_GAUSSIANNOISE", GaussianNoiseEvaluateOperator);
1444 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_IMPULSENOISE", ImpulseNoiseEvaluateOperator);
1445 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_LAPLACIANNOISE", LaplacianNoiseEvaluateOperator);
1446 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_MULTIPLICATIVENOISE", MultiplicativeNoiseEvaluateOperator);
1447 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_POISSONNOISE", PoissonNoiseEvaluateOperator);
1448 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_UNIFORMNOISE", UniformNoiseEvaluateOperator);
1449 #endif
1450 #if MagickLibVersion > 0x648
1451 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_COSINE", CosineEvaluateOperator);
1452 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_SINE", SineEvaluateOperator);
1453 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_ADDMODULUS", AddModulusEvaluateOperator);
1454 #endif
1455 #if MagickLibVersion >= 0x661
1456 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_MEAN", MeanEvaluateOperator);
1457 #endif
1458 #if MagickLibVersion >= 0x664
1459 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_ABS", AbsEvaluateOperator);
1460 #endif
1461 #if MagickLibVersion >= 0x666
1462 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_EXPONENTIAL", ExponentialEvaluateOperator);
1463 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_MEDIAN", MedianEvaluateOperator);
1464 #endif
1465 #if MagickLibVersion >= 0x676
1466 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_SUM", SumEvaluateOperator);
1467 #endif
1468 #if MagickLibVersion >= 0x690
1469 	IMAGICK_REGISTER_CONST_LONG("EVALUATE_ROOT_MEAN_SQUARE", RootMeanSquareEvaluateOperator);
1470 #endif
1471 
1472 #if MagickLibVersion >= 0x70B
1473     IMAGICK_REGISTER_CONST_LONG("EVALUATE_INVERSE_LOG", InverseLogEvaluateOperator);
1474 #endif
1475 
1476 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_UNDEFINED", UndefinedColorspace);
1477 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_RGB", RGBColorspace);
1478 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_GRAY", GRAYColorspace);
1479 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_TRANSPARENT", TransparentColorspace);
1480 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_OHTA", OHTAColorspace);
1481 #if MagickLibVersion < 0x700
1482 #if !defined(MAGICKCORE_EXCLUDE_DEPRECATED)
1483 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_LAB", LABColorspace);
1484 #endif
1485 #endif
1486 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_XYZ", XYZColorspace);
1487 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_YCBCR", YCbCrColorspace);
1488 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_YCC", YCCColorspace);
1489 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_YIQ", YIQColorspace);
1490 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_YPBPR", YPbPrColorspace);
1491 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_YUV", YUVColorspace);
1492 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_CMYK", CMYKColorspace);
1493 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_SRGB", sRGBColorspace);
1494 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_HSB", HSBColorspace);
1495 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_HSL", HSLColorspace);
1496 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_HWB", HWBColorspace);
1497 #if MagickLibVersion < 0x700
1498 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_REC601LUMA", Rec601LumaColorspace);
1499 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_REC709LUMA", Rec709LumaColorspace);
1500 #endif
1501 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_LOG", LogColorspace);
1502 #if MagickLibVersion >= 0x642
1503 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_CMY", CMYColorspace);
1504 #endif
1505 #if MagickLibVersion >= 0X679
1506 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_LUV", LuvColorspace);
1507 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_HCL", HCLColorspace);
1508 #endif
1509 #if MagickLibVersion >= 0x680
1510 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_LCH", LCHColorspace);
1511 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_LMS", LMSColorspace);
1512 #endif
1513 #if MagickLibVersion >= 0x686
1514 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_LCHAB", LCHabColorspace);
1515 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_LCHUV", LCHuvColorspace);
1516 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_SCRGB", scRGBColorspace);
1517 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_HSI", HSIColorspace);
1518 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_HSV", HSVColorspace);
1519 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_HCLP", HCLpColorspace);
1520 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_YDBDR", YDbDrColorspace);
1521 #endif
1522 
1523 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_REC601YCBCR", Rec601YCbCrColorspace);
1524 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_REC709YCBCR", Rec709YCbCrColorspace);
1525 #if MagickLibVersion >= 0x690
1526 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_XYY", xyYColorspace);
1527 #endif
1528 
1529 
1530 #if (MagickLibVersion >= 0x700 && MagickLibVersion >= 0x708) || (MagickLibVersion < 0x700 && MagickLibVersion >= 0x699)
1531 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_LINEARGRAY", LinearGRAYColorspace);
1532 #endif
1533 
1534 #if MagickLibVersion >= 0x70B
1535     IMAGICK_REGISTER_CONST_LONG("COLORSPACE_DISPLAYP3", DisplayP3Colorspace);
1536     IMAGICK_REGISTER_CONST_LONG("COLORSPACE_ADOBE98", Adobe98Colorspace);
1537     IMAGICK_REGISTER_CONST_LONG("COLORSPACE_PROPHOTO", ProPhotoColorspace);
1538 #endif
1539 
1540 #if MagickLibVersion >= 0x70A
1541 	IMAGICK_REGISTER_CONST_LONG("COLORSPACE_JZAZBZ", JzazbzColorspace);
1542 #endif
1543 
1544 	IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_UNDEFINED", UndefinedVirtualPixelMethod);
1545 	IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_BACKGROUND", BackgroundVirtualPixelMethod);
1546 #if MagickLibVersion < 0x700
1547 	IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_CONSTANT", ConstantVirtualPixelMethod);  /* deprecated */
1548 #endif
1549 	IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_EDGE", EdgeVirtualPixelMethod);
1550 	IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_MIRROR", MirrorVirtualPixelMethod);
1551 	IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_TILE", TileVirtualPixelMethod);
1552 	IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_TRANSPARENT", TransparentVirtualPixelMethod);
1553 #if MagickLibVersion > 0x641
1554 	IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_MASK", MaskVirtualPixelMethod);
1555 	IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_BLACK", BlackVirtualPixelMethod);
1556 	IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_GRAY", GrayVirtualPixelMethod);
1557 	IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_WHITE", WhiteVirtualPixelMethod);
1558 #endif
1559 #if MagickLibVersion > 0x642
1560 	IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_HORIZONTALTILE", HorizontalTileVirtualPixelMethod);
1561 	IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_VERTICALTILE", VerticalTileVirtualPixelMethod);
1562 #endif
1563 #if MagickLibVersion >= 0x651
1564 	IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_HORIZONTALTILEEDGE", HorizontalTileEdgeVirtualPixelMethod);
1565 	IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_VERTICALTILEEDGE", VerticalTileEdgeVirtualPixelMethod);
1566 	IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_CHECKERTILE", CheckerTileVirtualPixelMethod);
1567 #endif
1568 
1569 	// These were missed, but have been present for 12 years, so assuming
1570 	// they are going to be available in all version of ImageMagick people
1571 	// are using.
1572 	IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_DITHER", DitherVirtualPixelMethod);
1573 	IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_RANDOM", RandomVirtualPixelMethod);
1574 
1575 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_UNDEFINED", UndefinedPreview);
1576 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_ROTATE", RotatePreview);
1577 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_SHEAR", ShearPreview);
1578 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_ROLL", RollPreview);
1579 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_HUE", HuePreview);
1580 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_SATURATION", SaturationPreview);
1581 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_BRIGHTNESS", BrightnessPreview);
1582 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_GAMMA", GammaPreview);
1583 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_SPIFF", SpiffPreview);
1584 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_DULL", DullPreview);
1585 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_GRAYSCALE", GrayscalePreview);
1586 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_QUANTIZE", QuantizePreview);
1587 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_DESPECKLE", DespecklePreview);
1588 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_REDUCENOISE", ReduceNoisePreview);
1589 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_ADDNOISE", AddNoisePreview);
1590 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_SHARPEN", SharpenPreview);
1591 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_BLUR", BlurPreview);
1592 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_THRESHOLD", ThresholdPreview);
1593 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_EDGEDETECT", EdgeDetectPreview);
1594 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_SPREAD", SpreadPreview);
1595 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_SOLARIZE", SolarizePreview);
1596 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_SHADE", ShadePreview);
1597 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_RAISE", RaisePreview);
1598 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_SEGMENT", SegmentPreview);
1599 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_SWIRL", SwirlPreview);
1600 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_IMPLODE", ImplodePreview);
1601 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_WAVE", WavePreview);
1602 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_OILPAINT", OilPaintPreview);
1603 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_CHARCOALDRAWING", CharcoalDrawingPreview);
1604 	IMAGICK_REGISTER_CONST_LONG("PREVIEW_JPEG", JPEGPreview);
1605 	IMAGICK_REGISTER_CONST_LONG("RENDERINGINTENT_UNDEFINED", UndefinedIntent);
1606 	IMAGICK_REGISTER_CONST_LONG("RENDERINGINTENT_SATURATION", SaturationIntent);
1607 	IMAGICK_REGISTER_CONST_LONG("RENDERINGINTENT_PERCEPTUAL", PerceptualIntent);
1608 	IMAGICK_REGISTER_CONST_LONG("RENDERINGINTENT_ABSOLUTE", AbsoluteIntent);
1609 	IMAGICK_REGISTER_CONST_LONG("RENDERINGINTENT_RELATIVE", RelativeIntent);
1610 	IMAGICK_REGISTER_CONST_LONG("INTERLACE_UNDEFINED", UndefinedInterlace);
1611 	IMAGICK_REGISTER_CONST_LONG("INTERLACE_NO", NoInterlace);
1612 	IMAGICK_REGISTER_CONST_LONG("INTERLACE_LINE", LineInterlace);
1613 	IMAGICK_REGISTER_CONST_LONG("INTERLACE_PLANE", PlaneInterlace);
1614 	IMAGICK_REGISTER_CONST_LONG("INTERLACE_PARTITION", PartitionInterlace);
1615 #if MagickLibVersion > 0x633
1616 	IMAGICK_REGISTER_CONST_LONG("INTERLACE_GIF", GIFInterlace);
1617 	IMAGICK_REGISTER_CONST_LONG("INTERLACE_JPEG", JPEGInterlace);
1618 	IMAGICK_REGISTER_CONST_LONG("INTERLACE_PNG", PNGInterlace);
1619 #endif
1620 	IMAGICK_REGISTER_CONST_LONG("FILLRULE_UNDEFINED", UndefinedRule);
1621 	IMAGICK_REGISTER_CONST_LONG("FILLRULE_EVENODD", EvenOddRule);
1622 	IMAGICK_REGISTER_CONST_LONG("FILLRULE_NONZERO", NonZeroRule);
1623 	IMAGICK_REGISTER_CONST_LONG("PATHUNITS_UNDEFINED", UndefinedPathUnits);
1624 	IMAGICK_REGISTER_CONST_LONG("PATHUNITS_USERSPACE", UserSpace);
1625 	IMAGICK_REGISTER_CONST_LONG("PATHUNITS_USERSPACEONUSE", UserSpaceOnUse);
1626 	IMAGICK_REGISTER_CONST_LONG("PATHUNITS_OBJECTBOUNDINGBOX", ObjectBoundingBox);
1627 	IMAGICK_REGISTER_CONST_LONG("LINECAP_UNDEFINED", UndefinedCap);
1628 	IMAGICK_REGISTER_CONST_LONG("LINECAP_BUTT", ButtCap);
1629 	IMAGICK_REGISTER_CONST_LONG("LINECAP_ROUND", RoundCap);
1630 	IMAGICK_REGISTER_CONST_LONG("LINECAP_SQUARE", SquareCap);
1631 	IMAGICK_REGISTER_CONST_LONG("LINEJOIN_UNDEFINED", UndefinedJoin);
1632 	IMAGICK_REGISTER_CONST_LONG("LINEJOIN_MITER", MiterJoin);
1633 	IMAGICK_REGISTER_CONST_LONG("LINEJOIN_ROUND", RoundJoin);
1634 	IMAGICK_REGISTER_CONST_LONG("LINEJOIN_BEVEL", BevelJoin);
1635 	IMAGICK_REGISTER_CONST_LONG("RESOURCETYPE_UNDEFINED", UndefinedResource);
1636 	IMAGICK_REGISTER_CONST_LONG("RESOURCETYPE_AREA", AreaResource);
1637 	IMAGICK_REGISTER_CONST_LONG("RESOURCETYPE_DISK", DiskResource);
1638 	IMAGICK_REGISTER_CONST_LONG("RESOURCETYPE_FILE", FileResource);
1639 	IMAGICK_REGISTER_CONST_LONG("RESOURCETYPE_MAP", MapResource);
1640 	IMAGICK_REGISTER_CONST_LONG("RESOURCETYPE_MEMORY", MemoryResource);
1641 #if MagickLibVersion >= 0x675
1642 	IMAGICK_REGISTER_CONST_LONG("RESOURCETYPE_TIME", TimeResource);
1643 	IMAGICK_REGISTER_CONST_LONG("RESOURCETYPE_THROTTLE", ThrottleResource);
1644 #endif
1645 #if MagickLibVersion > 0x678
1646 	IMAGICK_REGISTER_CONST_LONG("RESOURCETYPE_THREAD", ThreadResource);
1647 #endif
1648 #if MagickLibVersion > 0x691
1649 	IMAGICK_REGISTER_CONST_LONG("RESOURCETYPE_WIDTH", WidthResource);
1650 	IMAGICK_REGISTER_CONST_LONG("RESOURCETYPE_HEIGHT", HeightResource);
1651 #endif
1652 
1653 #if (MagickLibVersion >= 0x700 && MagickLibVersion >= 0x708) || (MagickLibVersion < 0x700 && MagickLibVersion >= 0x69A)
1654     IMAGICK_REGISTER_CONST_LONG("RESOURCETYPE_LISTLENGTH", ListLengthResource);
1655 #endif
1656 
1657 	IMAGICK_REGISTER_CONST_LONG("DISPOSE_UNRECOGNIZED", UnrecognizedDispose);
1658 	IMAGICK_REGISTER_CONST_LONG("DISPOSE_UNDEFINED", UndefinedDispose);
1659 	IMAGICK_REGISTER_CONST_LONG("DISPOSE_NONE", NoneDispose);
1660 	IMAGICK_REGISTER_CONST_LONG("DISPOSE_BACKGROUND", BackgroundDispose);
1661 	IMAGICK_REGISTER_CONST_LONG("DISPOSE_PREVIOUS", PreviousDispose);
1662 #if MagickLibVersion > 0x631
1663 	IMAGICK_REGISTER_CONST_LONG("INTERPOLATE_UNDEFINED", UndefinedInterpolatePixel);
1664 
1665 	IMAGICK_REGISTER_CONST_LONG("INTERPOLATE_AVERAGE", AverageInterpolatePixel); /* Average 4 nearest neighbours */
1666 #if MagickLibVersion < 0x700
1667 	IMAGICK_REGISTER_CONST_LONG("INTERPOLATE_BICUBIC", BicubicInterpolatePixel); /* Catmull-Rom interpolation */
1668 #endif
1669 	IMAGICK_REGISTER_CONST_LONG("INTERPOLATE_BILINEAR", BilinearInterpolatePixel); /* Triangular filter interpolation */
1670 #if MagickLibVersion < 0x700
1671 	IMAGICK_REGISTER_CONST_LONG("INTERPOLATE_FILTER", FilterInterpolatePixel); /* Use resize filter - (very slow) */
1672 #endif
1673 	IMAGICK_REGISTER_CONST_LONG("INTERPOLATE_INTEGER", IntegerInterpolatePixel); /* Integer (floor) interpolation */
1674 	IMAGICK_REGISTER_CONST_LONG("INTERPOLATE_MESH", MeshInterpolatePixel); /* Triangular mesh interpolation */
1675 #if MagickLibVersion < 0x700
1676 	IMAGICK_REGISTER_CONST_LONG("INTERPOLATE_NEARESTNEIGHBOR", NearestNeighborInterpolatePixel);
1677 #endif
1678 #endif
1679 #if MagickLibVersion > 0x634
1680 	IMAGICK_REGISTER_CONST_LONG("INTERPOLATE_SPLINE", SplineInterpolatePixel); /* Cubic Spline (blurred) interpolation */
1681 #endif
1682 #if MagickLibVersion > 0x690
1683 	IMAGICK_REGISTER_CONST_LONG("INTERPOLATE_AVERAGE_9", Average9InterpolatePixel); /* Average 9 nearest neighbours */
1684 	IMAGICK_REGISTER_CONST_LONG("INTERPOLATE_AVERAGE_16", Average16InterpolatePixel); /* Average 16 nearest neighbours */
1685 	IMAGICK_REGISTER_CONST_LONG("INTERPOLATE_BLEND", BlendInterpolatePixel); /* blend of nearest 1, 2 or 4 pixels */
1686 	IMAGICK_REGISTER_CONST_LONG("INTERPOLATE_BACKGROUND_COLOR", BackgroundInterpolatePixel); /* just return background color */
1687 #if MagickLibVersion >= 0x687
1688 	IMAGICK_REGISTER_CONST_LONG("INTERPOLATE_CATROM", CatromInterpolatePixel); /* Catmull-Rom interpolation */
1689 #endif
1690 #endif
1691 
1692 #if MagickLibVersion >= 0x701
1693 	IMAGICK_REGISTER_CONST_LONG("INTERPOLATE_NEAREST_PIXEL", NearestInterpolatePixel); /* NearestInterpolatePixel */
1694 #endif
1695 
1696 #if MagickLibVersion > 0x628
1697 	IMAGICK_REGISTER_CONST_LONG("LAYERMETHOD_UNDEFINED", UndefinedLayer);
1698 	IMAGICK_REGISTER_CONST_LONG("LAYERMETHOD_COALESCE", CoalesceLayer);
1699 	IMAGICK_REGISTER_CONST_LONG("LAYERMETHOD_COMPAREANY", CompareAnyLayer);
1700 	IMAGICK_REGISTER_CONST_LONG("LAYERMETHOD_COMPARECLEAR", CompareClearLayer);
1701 	IMAGICK_REGISTER_CONST_LONG("LAYERMETHOD_COMPAREOVERLAY", CompareOverlayLayer);
1702 	IMAGICK_REGISTER_CONST_LONG("LAYERMETHOD_DISPOSE", DisposeLayer);
1703 	IMAGICK_REGISTER_CONST_LONG("LAYERMETHOD_OPTIMIZE", OptimizeLayer);
1704 	IMAGICK_REGISTER_CONST_LONG("LAYERMETHOD_OPTIMIZEPLUS", OptimizePlusLayer);
1705 #endif
1706 #if MagickLibVersion > 0x632
1707 	IMAGICK_REGISTER_CONST_LONG("LAYERMETHOD_OPTIMIZETRANS", OptimizeTransLayer);
1708 	IMAGICK_REGISTER_CONST_LONG("LAYERMETHOD_COMPOSITE", CompositeLayer);
1709 	IMAGICK_REGISTER_CONST_LONG("LAYERMETHOD_OPTIMIZEIMAGE", OptimizeImageLayer);
1710 	IMAGICK_REGISTER_CONST_LONG("LAYERMETHOD_REMOVEDUPS", RemoveDupsLayer);
1711 	IMAGICK_REGISTER_CONST_LONG("LAYERMETHOD_REMOVEZERO", RemoveZeroLayer);
1712 #endif
1713 #if MagickLibVersion >= 0x644
1714 	IMAGICK_REGISTER_CONST_LONG("LAYERMETHOD_TRIMBOUNDS", TrimBoundsLayer);
1715 #endif
1716 #if MagickLibVersion > 0x629
1717 	IMAGICK_REGISTER_CONST_LONG("ORIENTATION_UNDEFINED", UndefinedOrientation);
1718 	IMAGICK_REGISTER_CONST_LONG("ORIENTATION_TOPLEFT", TopLeftOrientation);
1719 	IMAGICK_REGISTER_CONST_LONG("ORIENTATION_TOPRIGHT", TopRightOrientation);
1720 	IMAGICK_REGISTER_CONST_LONG("ORIENTATION_BOTTOMRIGHT", BottomRightOrientation);
1721 	IMAGICK_REGISTER_CONST_LONG("ORIENTATION_BOTTOMLEFT", BottomLeftOrientation);
1722 	IMAGICK_REGISTER_CONST_LONG("ORIENTATION_LEFTTOP", LeftTopOrientation);
1723 	IMAGICK_REGISTER_CONST_LONG("ORIENTATION_RIGHTTOP", RightTopOrientation);
1724 	IMAGICK_REGISTER_CONST_LONG("ORIENTATION_RIGHTBOTTOM", RightBottomOrientation);
1725 	IMAGICK_REGISTER_CONST_LONG("ORIENTATION_LEFTBOTTOM", LeftBottomOrientation);
1726 #endif
1727 #if MagickLibVersion > 0x635
1728 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_UNDEFINED", UndefinedDistortion);
1729 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_AFFINE", AffineDistortion);
1730 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_AFFINEPROJECTION", AffineProjectionDistortion);
1731 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_ARC", ArcDistortion);
1732 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_BILINEAR", BilinearDistortion);
1733 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_PERSPECTIVE", PerspectiveDistortion);
1734 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_PERSPECTIVEPROJECTION", PerspectiveProjectionDistortion);
1735 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_SCALEROTATETRANSLATE", ScaleRotateTranslateDistortion);
1736 #endif
1737 #if MagickLibVersion > 0x645
1738 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_POLYNOMIAL", PolynomialDistortion);
1739 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_POLAR", PolarDistortion);
1740 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_DEPOLAR", DePolarDistortion);
1741 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_BARREL", BarrelDistortion);
1742 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_SHEPARDS", ShepardsDistortion);
1743 
1744 	// SentinelDistortion is not a real distortion type. It is a guard value
1745 	// that shouldn't have been exposed in Imagick. TODO remove at next
1746 	// minor version.
1747 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_SENTINEL", SentinelDistortion);
1748 #endif
1749 
1750 #if MagickLibVersion >= 0x70B
1751     IMAGICK_REGISTER_CONST_LONG("DISTORTION_RIGID_AFFINE", RigidAffineDistortion);
1752 #endif
1753 
1754 #if MagickLibVersion >= 0x644
1755 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_BARRELINVERSE", BarrelInverseDistortion);
1756 #endif
1757 #if MagickLibVersion >= 0x654
1758 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_BILINEARFORWARD", BilinearForwardDistortion);
1759 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_BILINEARREVERSE", BilinearReverseDistortion);
1760 #endif
1761 #if MagickLibVersion >= 0x670
1762 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_RESIZE", ResizeDistortion);
1763 #endif
1764 #if MagickLibVersion >= 0x671
1765 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_CYLINDER2PLANE", Cylinder2PlaneDistortion);
1766 	IMAGICK_REGISTER_CONST_LONG("DISTORTION_PLANE2CYLINDER", Plane2CylinderDistortion);
1767 #endif
1768 #if MagickLibVersion > 0x636
1769 	IMAGICK_REGISTER_CONST_LONG("LAYERMETHOD_MERGE", MergeLayer);
1770 	IMAGICK_REGISTER_CONST_LONG("LAYERMETHOD_FLATTEN", FlattenLayer);
1771 	IMAGICK_REGISTER_CONST_LONG("LAYERMETHOD_MOSAIC", MosaicLayer);
1772 #endif
1773 #if MagickLibVersion > 0x637
1774 	IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_ACTIVATE", ActivateAlphaChannel);
1775 #if MagickLibVersion >= 0x700
1776 	IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_ON", OnAlphaChannel);
1777 #else
1778 	IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_RESET", ResetAlphaChannel);
1779 #endif
1780 	IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_SET", SetAlphaChannel);
1781 #endif
1782 #if MagickLibVersion > 0x645
1783 	IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_UNDEFINED", UndefinedAlphaChannel);
1784 #if MagickLibVersion >= 0x700
1785 	IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_DISCRETE", DiscreteAlphaChannel);
1786 #else
1787 	IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_COPY", CopyAlphaChannel);
1788 #endif
1789 	IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_DEACTIVATE", DeactivateAlphaChannel);
1790 	IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_EXTRACT", ExtractAlphaChannel);
1791 #if MagickLibVersion >= 0x700
1792 	IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_OFF", OffAlphaChannel);
1793 #else
1794 	IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_OPAQUE", OpaqueAlphaChannel);
1795 #endif
1796 	IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_SHAPE", ShapeAlphaChannel);
1797 	IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_TRANSPARENT", TransparentAlphaChannel);
1798 #if MagickLibVersion >= 0x690
1799 	IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_ASSOCIATE", AssociateAlphaChannel);
1800 	IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_DISSOCIATE", DisassociateAlphaChannel);
1801 #endif
1802 	/*
1803 	 DiscreteAlphaChannel,                  CopyAlphaChannel,
1804 	 DisassociateAlphaChannel,              DeactivateAlphaChannel,
1805 	 ExtractAlphaChannel,                   ExtractAlphaChannel,
1806 	 OffAlphaChannel,                       OpaqueAlphaChannel,
1807 	 OnAlphaChannel,                        ResetAlphaChannel,  // deprecated
1808 	*/
1809 
1810 	IMAGICK_REGISTER_CONST_LONG("SPARSECOLORMETHOD_UNDEFINED", UndefinedColorInterpolate);
1811 	IMAGICK_REGISTER_CONST_LONG("SPARSECOLORMETHOD_BARYCENTRIC", BarycentricColorInterpolate);
1812 	IMAGICK_REGISTER_CONST_LONG("SPARSECOLORMETHOD_BILINEAR", BilinearColorInterpolate);
1813 	IMAGICK_REGISTER_CONST_LONG("SPARSECOLORMETHOD_POLYNOMIAL", PolynomialColorInterpolate);
1814 	IMAGICK_REGISTER_CONST_LONG("SPARSECOLORMETHOD_SPEPARDS", ShepardsColorInterpolate);
1815 	IMAGICK_REGISTER_CONST_LONG("SPARSECOLORMETHOD_VORONOI", VoronoiColorInterpolate);
1816 #if MagickLibVersion >= 0x687
1817 	IMAGICK_REGISTER_CONST_LONG("SPARSECOLORMETHOD_INVERSE", InverseColorInterpolate);
1818 #endif
1819 #if MagickLibVersion >= 0x693
1820 	IMAGICK_REGISTER_CONST_LONG("SPARSECOLORMETHOD_MANHATTAN", ManhattanColorInterpolate);
1821 #endif
1822 	IMAGICK_REGISTER_CONST_LONG("DITHERMETHOD_UNDEFINED", UndefinedDitherMethod);
1823 	IMAGICK_REGISTER_CONST_LONG("DITHERMETHOD_NO", NoDitherMethod);
1824 	IMAGICK_REGISTER_CONST_LONG("DITHERMETHOD_RIEMERSMA", RiemersmaDitherMethod);
1825 	IMAGICK_REGISTER_CONST_LONG("DITHERMETHOD_FLOYDSTEINBERG", FloydSteinbergDitherMethod);
1826 #endif
1827 #if MagickLibVersion > 0x648
1828 	IMAGICK_REGISTER_CONST_LONG("FUNCTION_UNDEFINED", UndefinedFunction);
1829 	IMAGICK_REGISTER_CONST_LONG("FUNCTION_POLYNOMIAL", PolynomialFunction);
1830 	IMAGICK_REGISTER_CONST_LONG("FUNCTION_SINUSOID", SinusoidFunction);
1831 #endif
1832 #if MagickLibVersion >= 0x653
1833 	IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_BACKGROUND", BackgroundAlphaChannel);
1834 	IMAGICK_REGISTER_CONST_LONG("FUNCTION_ARCSIN", ArcsinFunction);
1835 	IMAGICK_REGISTER_CONST_LONG("FUNCTION_ARCTAN", ArctanFunction);
1836 #endif
1837 #if MagickLibVersion >= 0x678
1838 #if MagickLibVersion < 0x700
1839 	IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_FLATTEN", FlattenAlphaChannel);
1840 #endif
1841 	IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_REMOVE", RemoveAlphaChannel);
1842 #endif
1843 
1844 #if MagickLibVersion > 0x683
1845 	IMAGICK_REGISTER_CONST_LONG("STATISTIC_GRADIENT", GradientStatistic);
1846 	IMAGICK_REGISTER_CONST_LONG("STATISTIC_MAXIMUM", MaximumStatistic);
1847 	IMAGICK_REGISTER_CONST_LONG("STATISTIC_MEAN", MeanStatistic);
1848 	IMAGICK_REGISTER_CONST_LONG("STATISTIC_MEDIAN", MedianStatistic);
1849 	IMAGICK_REGISTER_CONST_LONG("STATISTIC_MINIMUM", MinimumStatistic);
1850 	IMAGICK_REGISTER_CONST_LONG("STATISTIC_MODE", ModeStatistic);
1851 	IMAGICK_REGISTER_CONST_LONG("STATISTIC_NONPEAK", NonpeakStatistic);
1852 	IMAGICK_REGISTER_CONST_LONG("STATISTIC_STANDARD_DEVIATION", StandardDeviationStatistic);
1853 #endif
1854 #if MagickLibVersion >= 0x690
1855 	IMAGICK_REGISTER_CONST_LONG("STATISTIC_ROOT_MEAN_SQUARE", RootMeanSquareStatistic);
1856 #endif
1857 
1858 #if MagickLibVersion >= 0x70C
1859 	IMAGICK_REGISTER_CONST_LONG("STATISTIC_CONTRAST", ContrastStatistic);
1860 #endif
1861 
1862 #ifdef IMAGICK_WITH_KERNEL
1863 /* Convolve / Correlate weighted sums */
1864 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_CONVOLVE", ConvolveMorphology); /* Weighted Sum with reflected kernel */
1865 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_CORRELATE", CorrelateMorphology); /* Weighted Sum using a sliding window */
1866 /* Low-level Morphology methods */
1867 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_ERODE", ErodeMorphology);  /* Minimum Value in Neighbourhood */
1868 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_DILATE", DilateMorphology);  /* Maximum Value in Neighbourhood */
1869 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_ERODE_INTENSITY", ErodeIntensityMorphology); /* Pixel Pick using GreyScale Erode */
1870 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_DILATE_INTENSITY", DilateIntensityMorphology); /* Pixel Pick using GreyScale Dialate */
1871 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_DISTANCE",  DistanceMorphology); /* Add Kernel Value, take Minimum */
1872 /* Second-level Morphology methods */
1873 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_OPEN", OpenMorphology); /* Dilate then Erode */
1874 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_CLOSE", CloseMorphology); /* Erode then Dilate */
1875 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_OPEN_INTENSITY", OpenIntensityMorphology); /* Pixel Pick using GreyScale Open */
1876 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_CLOSE_INTENSITY", CloseIntensityMorphology); /* Pixel Pick using GreyScale Close */
1877 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_SMOOTH", SmoothMorphology); /* Open then Close */
1878 /* Difference Morphology methods */
1879 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_EDGE_IN", EdgeInMorphology); /* Dilate difference from Original */
1880 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_EDGE_OUT", EdgeOutMorphology); /* Erode difference from Original */
1881 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_EDGE", EdgeMorphology); /* Dilate difference with Erode */
1882 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_TOP_HAT", TopHatMorphology); /* Close difference from Original */
1883 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_BOTTOM_HAT", BottomHatMorphology); /* Open difference from Original */
1884 /* Recursive Morphology methods */
1885 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_HIT_AND_MISS", HitAndMissMorphology); /* Foreground/Background pattern matching */
1886 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_THINNING", ThinningMorphology); /* Remove matching pixels from image */
1887 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_THICKEN", ThickenMorphology); /* Add matching pixels from image */
1888 /* Experimental Morphology methods */
1889 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_VORONOI", VoronoiMorphology); /* distance matte channel copy nearest color */
1890 IMAGICK_REGISTER_CONST_LONG("MORPHOLOGY_ITERATIVE", IterativeDistanceMorphology); /* Add Kernel Value, take Minimum */
1891 
1892 
1893 /* The no-op or 'original image' kernel */
1894 IMAGICK_REGISTER_CONST_LONG("KERNEL_UNITY", UnityKernel);
1895 /* Convolution Kernels, Gaussian Based */
1896 IMAGICK_REGISTER_CONST_LONG("KERNEL_GAUSSIAN", GaussianKernel);
1897 IMAGICK_REGISTER_CONST_LONG("KERNEL_DIFFERENCE_OF_GAUSSIANS", DoGKernel);
1898 IMAGICK_REGISTER_CONST_LONG("KERNEL_LAPLACIAN_OF_GAUSSIANS", LoGKernel);
1899 IMAGICK_REGISTER_CONST_LONG("KERNEL_BLUR", BlurKernel);
1900 IMAGICK_REGISTER_CONST_LONG("KERNEL_COMET", CometKernel);
1901 /* Convolution Kernels, by Name */
1902 IMAGICK_REGISTER_CONST_LONG("KERNEL_LAPLACIAN", LaplacianKernel);
1903 IMAGICK_REGISTER_CONST_LONG("KERNEL_SOBEL", SobelKernel);
1904 IMAGICK_REGISTER_CONST_LONG("KERNEL_FREI_CHEN", FreiChenKernel);
1905 IMAGICK_REGISTER_CONST_LONG("KERNEL_ROBERTS", RobertsKernel);
1906 IMAGICK_REGISTER_CONST_LONG("KERNEL_PREWITT", PrewittKernel);
1907 IMAGICK_REGISTER_CONST_LONG("KERNEL_COMPASS", CompassKernel);
1908 IMAGICK_REGISTER_CONST_LONG("KERNEL_KIRSCH", KirschKernel);
1909 /* Shape Kernels */
1910 IMAGICK_REGISTER_CONST_LONG("KERNEL_DIAMOND", DiamondKernel);
1911 IMAGICK_REGISTER_CONST_LONG("KERNEL_SQUARE", SquareKernel);
1912 IMAGICK_REGISTER_CONST_LONG("KERNEL_RECTANGLE", RectangleKernel);
1913 IMAGICK_REGISTER_CONST_LONG("KERNEL_OCTAGON", OctagonKernel);
1914 IMAGICK_REGISTER_CONST_LONG("KERNEL_DISK", DiskKernel);
1915 IMAGICK_REGISTER_CONST_LONG("KERNEL_PLUS", PlusKernel);
1916 IMAGICK_REGISTER_CONST_LONG("KERNEL_CROSS", CrossKernel);
1917 IMAGICK_REGISTER_CONST_LONG("KERNEL_RING", RingKernel);
1918 /* Hit And Miss Kernels */
1919 IMAGICK_REGISTER_CONST_LONG("KERNEL_PEAKS", PeaksKernel);
1920 IMAGICK_REGISTER_CONST_LONG("KERNEL_EDGES", EdgesKernel);
1921 IMAGICK_REGISTER_CONST_LONG("KERNEL_CORNERS", CornersKernel);
1922 IMAGICK_REGISTER_CONST_LONG("KERNEL_DIAGONALS", DiagonalsKernel);
1923 IMAGICK_REGISTER_CONST_LONG("KERNEL_LINE_ENDS", LineEndsKernel);
1924 IMAGICK_REGISTER_CONST_LONG("KERNEL_LINE_JUNCTIONS", LineJunctionsKernel);
1925 IMAGICK_REGISTER_CONST_LONG("KERNEL_RIDGES", RidgesKernel);
1926 IMAGICK_REGISTER_CONST_LONG("KERNEL_CONVEX_HULL", ConvexHullKernel);
1927 IMAGICK_REGISTER_CONST_LONG("KERNEL_THIN_SE", ThinSEKernel);
1928 IMAGICK_REGISTER_CONST_LONG("KERNEL_SKELETON", SkeletonKernel);
1929 /* Distance Measuring Kernels */
1930 IMAGICK_REGISTER_CONST_LONG("KERNEL_CHEBYSHEV", ChebyshevKernel);
1931 IMAGICK_REGISTER_CONST_LONG("KERNEL_MANHATTAN", ManhattanKernel);
1932 IMAGICK_REGISTER_CONST_LONG("KERNEL_OCTAGONAL", OctagonalKernel);
1933 IMAGICK_REGISTER_CONST_LONG("KERNEL_EUCLIDEAN", EuclideanKernel);
1934 /* User Specified Kernel Array */
1935 IMAGICK_REGISTER_CONST_LONG("KERNEL_USER_DEFINED", UserDefinedKernel);
1936 IMAGICK_REGISTER_CONST_LONG("KERNEL_BINOMIAL", BinomialKernel);
1937 
1938 /* Draw directions */
1939 IMAGICK_REGISTER_CONST_LONG("DIRECTION_LEFT_TO_RIGHT", LeftToRightDirection);
1940 IMAGICK_REGISTER_CONST_LONG("DIRECTION_RIGHT_TO_LEFT", RightToLeftDirection);
1941 
1942 // The kernel is scaled directly using given scaling factor without change.
1943 IMAGICK_REGISTER_CONST_LONG("NORMALIZE_KERNEL_NONE", 0);
1944 // Kernel normalization ('normalize_flags' given) is designed to ensure
1945 // that any use of the kernel scaling factor with 'Convolve' or 'Correlate'
1946 // morphology methods will fall into -1.0 to +1.0 range.
1947 IMAGICK_REGISTER_CONST_LONG("NORMALIZE_KERNEL_VALUE", NormalizeValue);
1948 // For special kernels designed for locating shapes using 'Correlate', (often
1949 // only containing +1 and -1 values, representing foreground/brackground
1950 // matching) a special normalization method is provided to scale the positive
1951 // values separately to those of the negative values, so the kernel will be
1952 // forced to become a zero-sum kernel better suited to such searches.
1953 IMAGICK_REGISTER_CONST_LONG("NORMALIZE_KERNEL_CORRELATE", CorrelateNormalizeValue);
1954 // Scale the kernel by a percent.
1955 IMAGICK_REGISTER_CONST_LONG("NORMALIZE_KERNEL_PERCENT", PercentValue);
1956 #endif
1957 
1958 
1959 #if IM_HAVE_IMAGICK_GETSETIMAGEMASK
1960 IMAGICK_REGISTER_CONST_LONG("PIXELMASK_READ", ReadPixelMask);
1961 IMAGICK_REGISTER_CONST_LONG("PIXELMASK_WRITE", WritePixelMask);
1962 #endif
1963 
1964 
1965 #if MagickLibVersion >= 0x708
1966 IMAGICK_REGISTER_CONST_LONG("PIXELMASK_COMPOSITE", CompositePixelMask);
1967 #endif
1968 
1969 #undef IMAGICK_REGISTER_CONST_LONG
1970 #undef IMAGICK_REGISTER_CONST_STRING
1971 }
1972