1 2 #ifndef PHP_IMAGEMAGICK_VERSION_DEFS_H 3 # define PHP_IMAGEMAGICK_VERSION_DEFS_H 4 5 // Q) Why are the defines done in this file? 6 // 7 // A) Checking whether an ImageMagick function is available _and_ usable is 8 // annoyingly difficult. It's pretty common for new functions to be introduced 9 // in patch releases, (e.g. 6.5.4-8) rather than in minor releases (6.5.5-0). 10 // 11 // Additionally, the api for new functions often changes quite rapidly in the 12 // first few versions it is available in, which means we can't just check for 13 // the presence of the symbol 14 // 15 // Because of those two things, the sanest thing to do is to support features 16 // based on the minimum minor version from which they are continually 17 // available and stable. 18 // 19 // Any mistake in which version is required for a feature can be fixed in a 20 // single place, rather than having to have duplicated info elsewhere. 21 22 23 #if MagickLibVersion >= 0x700 24 #if MagickLibVersion >= 0x702 25 #define IM_HAVE_IMAGICK_SETIMAGEINTERPOLATEMETHOD 1 26 #endif 27 #elif MagickLibVersion >= 0x631 28 #define IM_HAVE_IMAGICK_SETIMAGEINTERPOLATEMETHOD 1 29 #endif 30 31 32 #if MagickLibVersion >= 0x709 33 #define IM_HAVE_IMAGICK_SETIMAGEPIXELCOLOR 1 34 #endif 35 36 37 #if MagickLibVersion >= 0x70A 38 // Technically, this may be available earlier, but the behaviour around 39 // default mask changed. 40 #define IM_HAVE_IMAGICK_GETSETIMAGEMASK 1 41 42 // ImageMagick forget to export the header until about 7.0.11-14... 43 WandExport MagickBooleanType MagickSetImageMask( 44 MagickWand *wand, const PixelMask type, const MagickWand *clip_mask 45 ); 46 47 #endif 48 49 // The above is sub-optimal as it's hard to read. It'd be better to do 50 // something like the below: 51 52 //#define MAGICK_LIB_RANGE(NAME, IM6_VERSION, IM7_VERSION) slash 53 //#if MagickLibVersion >= 0x700 slash 54 // #if MagickLibVersion >= IM7_VERSION slash 55 // #define IM_HAVE_##NAME 1 slash 56 // #endif slash 57 //#elif MagickLibVersion >= 0x600 slash 58 // #if MagickLibVersion >= IM6_VERSION slash 59 // #define IM_HAVE_##NAME 1 slash 60 // #endif slash 61 //#endif 62 63 // MAGICK_LIB_RANGE(IMAGICK_SETIMAGEINTERPOLATEMETHOD, 0x631, 0x702) 64 65 // But this type of macro expansion is not possible. 66 // 67 // https://stackoverflow.com/questions/48431325/is-it-possible-to-define-macro-inside-macro 68 // "The resulting completely macro-replaced preprocessing token sequence is not 69 // processed as a preprocessing directive even if it resembles one,..." 70 // 71 // An alternative would be to use code generation to build the define file as 72 // part of the build process. However that would involve looking at m4 config files. 73 74 75 #if MagickLibVersion >= 0x700 76 // declare symbols only defined in C source and not in header 77 WandExport MagickBooleanType MagickSetImageMask( 78 MagickWand *wand, const PixelMask type, const MagickWand *clip_mask 79 ); 80 #endif 81 82 #endif /* PHP_IMAGEMAGICK_VERSION_DEFS_H */