1 /* 2 +----------------------------------------------------------------------+ 3 | Copyright (c) The PHP Group | 4 +----------------------------------------------------------------------+ 5 | This source file is subject to version 3.01 of the PHP license, | 6 | that is bundled with this package in the file LICENSE, and is | 7 | available through the world-wide-web at the following url: | 8 | https://www.php.net/license/3_01.txt | 9 | If you did not receive a copy of the PHP license and are unable to | 10 | obtain it through the world-wide-web, please send a note to | 11 | license@php.net so we can mail you a copy immediately. | 12 +----------------------------------------------------------------------+ 13 | Authors: Rasmus Lerdorf <rasmus@php.net> | 14 | Stig Bakken <ssb@php.net> | 15 +----------------------------------------------------------------------+ 16 */ 17 18 #ifndef PHP_GD_H 19 #define PHP_GD_H 20 21 #include "zend_string.h" 22 #include "php_streams.h" 23 24 #if defined(HAVE_LIBGD) || defined(HAVE_GD_BUNDLED) 25 26 /* open_basedir and safe_mode checks */ 27 #define PHP_GD_CHECK_OPEN_BASEDIR(filename, errormsg) \ 28 if (!filename || php_check_open_basedir(filename)) { \ 29 php_error_docref(NULL, E_WARNING, errormsg); \ 30 RETURN_FALSE; \ 31 } 32 33 #define PHP_GDIMG_TYPE_GIF 1 34 #define PHP_GDIMG_TYPE_PNG 2 35 #define PHP_GDIMG_TYPE_JPG 3 36 #define PHP_GDIMG_TYPE_WBM 4 37 #define PHP_GDIMG_TYPE_XBM 5 38 #define PHP_GDIMG_TYPE_XPM 6 39 #define PHP_GDIMG_TYPE_GD 8 40 #define PHP_GDIMG_TYPE_GD2 9 41 #define PHP_GDIMG_TYPE_GD2PART 10 42 #define PHP_GDIMG_TYPE_WEBP 11 43 #define PHP_GDIMG_TYPE_BMP 12 44 #define PHP_GDIMG_TYPE_TGA 13 45 #define PHP_GDIMG_TYPE_AVIF 14 46 47 #define PHP_IMG_GIF 1 48 #define PHP_IMG_JPG 2 49 #define PHP_IMG_JPEG 2 50 #define PHP_IMG_PNG 4 51 #define PHP_IMG_WBMP 8 52 #define PHP_IMG_XPM 16 53 #define PHP_IMG_WEBP 32 54 #define PHP_IMG_BMP 64 55 #define PHP_IMG_TGA 128 56 #define PHP_IMG_AVIF 256 57 58 /* Section Filters Declarations */ 59 /* IMPORTANT NOTE FOR NEW FILTER 60 * Do not forget to update: 61 * IMAGE_FILTER_MAX: define the last filter index 62 * IMAGE_FILTER_MAX_ARGS: define the biggest amount of arguments 63 * image_filter array in PHP_FUNCTION(imagefilter) 64 * */ 65 #define IMAGE_FILTER_NEGATE 0 66 #define IMAGE_FILTER_GRAYSCALE 1 67 #define IMAGE_FILTER_BRIGHTNESS 2 68 #define IMAGE_FILTER_CONTRAST 3 69 #define IMAGE_FILTER_COLORIZE 4 70 #define IMAGE_FILTER_EDGEDETECT 5 71 #define IMAGE_FILTER_EMBOSS 6 72 #define IMAGE_FILTER_GAUSSIAN_BLUR 7 73 #define IMAGE_FILTER_SELECTIVE_BLUR 8 74 #define IMAGE_FILTER_MEAN_REMOVAL 9 75 #define IMAGE_FILTER_SMOOTH 10 76 #define IMAGE_FILTER_PIXELATE 11 77 #define IMAGE_FILTER_SCATTER 12 78 #define IMAGE_FILTER_MAX 12 79 #define IMAGE_FILTER_MAX_ARGS 6 80 81 #ifdef HAVE_GD_BUNDLED 82 #define GD_BUNDLED 1 83 #else 84 #define GD_BUNDLED 0 85 #endif 86 87 #ifdef PHP_WIN32 88 # ifdef PHP_GD_EXPORTS 89 # define PHP_GD_API __declspec(dllexport) 90 # else 91 # define PHP_GD_API __declspec(dllimport) 92 # endif 93 #elif defined(__GNUC__) && __GNUC__ >= 4 94 # define PHP_GD_API __attribute__ ((visibility("default"))) 95 #else 96 # define PHP_GD_API 97 #endif 98 99 PHPAPI extern const char php_sig_gif[3]; 100 PHPAPI extern const char php_sig_jpg[3]; 101 PHPAPI extern const char php_sig_png[8]; 102 PHPAPI extern const char php_sig_bmp[2]; 103 PHPAPI extern const char php_sig_riff[4]; 104 PHPAPI extern const char php_sig_webp[4]; 105 PHPAPI extern const char php_sig_avif[4]; 106 107 extern zend_module_entry gd_module_entry; 108 #define phpext_gd_ptr &gd_module_entry 109 110 #include "php_version.h" 111 #define PHP_GD_VERSION PHP_VERSION 112 113 /* gd.c functions */ 114 PHP_MINFO_FUNCTION(gd); 115 PHP_MINIT_FUNCTION(gd); 116 PHP_MSHUTDOWN_FUNCTION(gd); 117 PHP_RSHUTDOWN_FUNCTION(gd); 118 119 PHP_GD_API struct gdImageStruct *php_gd_libgdimageptr_from_zval_p(zval* zp); 120 121 #else 122 123 #define phpext_gd_ptr NULL 124 125 #endif 126 127 #endif /* PHP_GD_H */ 128