-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(main/php-imagick): Backport patch for php 8.4 compatibility
- Loading branch information
Showing
2 changed files
with
180 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
diff -u -r ../imagick-3.7.0/imagick.c ./imagick.c | ||
--- ../imagick-3.7.0/imagick.c 2022-01-11 14:53:27.000000000 +0000 | ||
+++ ./imagick.c 2025-01-10 16:44:16.802405616 +0000 | ||
@@ -603,7 +603,7 @@ | ||
if (format) { | ||
retval = rv; | ||
ZVAL_STRING(retval, format); | ||
- php_strtolower(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); | ||
+ zend_str_tolower(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); | ||
IMAGICK_FREE_MAGICK_MEMORY(format); | ||
} else { | ||
retval = rv; | ||
@@ -676,7 +676,7 @@ | ||
if (format) { | ||
retval = rv; | ||
ZVAL_STRING(retval, format); | ||
- php_strtolower(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); | ||
+ zend_str_tolower(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); | ||
IMAGICK_FREE_MAGICK_MEMORY(format); | ||
} else { | ||
retval = rv; | ||
@@ -759,7 +759,7 @@ | ||
|
||
if (format) { | ||
ZVAL_STRING(retval, format, 1); | ||
- php_strtolower(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); | ||
+ zend_str_tolower(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); | ||
IMAGICK_FREE_MAGICK_MEMORY(format); | ||
} else { | ||
ZVAL_STRING(retval, "", 1); | ||
diff -u -r ../imagick-3.7.0/imagick_helpers.c ./imagick_helpers.c | ||
--- ../imagick-3.7.0/imagick_helpers.c 2022-01-11 14:53:27.000000000 +0000 | ||
+++ ./imagick_helpers.c 2025-01-10 16:45:24.881208147 +0000 | ||
@@ -23,6 +23,25 @@ | ||
#include "php_imagick_macros.h" | ||
#include "php_imagick_helpers.h" | ||
|
||
+#define EXTRACT_BUILD_NUMBER(str) ({ \ | ||
+ int build = 0; \ | ||
+ const char *s = str; \ | ||
+ while (*s && !isdigit(*s)) s++; \ | ||
+ if (*s) build = atoi(s); \ | ||
+ build; \ | ||
+}) | ||
+ | ||
+#define MAGICK_LIB_VERSION_MAJOR ((MagickLibVersion >> 8) & 0xFF) | ||
+#define MAGICK_LIB_VERSION_MINOR ((MagickLibVersion >> 4) & 0xF) | ||
+#define MAGICK_LIB_VERSION_PATCH (MagickLibVersion & 0xF) | ||
+#define MAGICK_LIB_VERSION_BUILD EXTRACT_BUILD_NUMBER(MagickLibAddendum) | ||
+ | ||
+#define MAGICK_LIB_VERSION_GTE(major, minor, patch, build) \ | ||
+ ((VERSION_MAJOR > (major)) || \ | ||
+ (VERSION_MAJOR == (major) && VERSION_MINOR > (minor)) || \ | ||
+ (VERSION_MAJOR == (major) && VERSION_MINOR == (minor) && VERSION_PATCH > (patch)) || \ | ||
+ (VERSION_MAJOR == (major) && VERSION_MINOR == (minor) && VERSION_PATCH == (patch) && VERSION_BUILD >= (build))) | ||
+ | ||
MagickBooleanType php_imagick_progress_monitor(const char *text, const MagickOffsetType offset, const MagickSizeType span, void *client_data) | ||
{ | ||
FILE *fp; | ||
@@ -1197,6 +1216,10 @@ | ||
#if MagickLibVersion >= 0x707 | ||
IMAGICK_REGISTER_CONST_LONG("FILTER_CUBIC_SPLINE", CubicSplineFilter); | ||
#endif | ||
+#if MAGICK_LIB_VERSION_GTE(7, 1, 1, 40) | ||
+ IMAGICK_REGISTER_CONST_LONG("FILTER_MAGIC_KERNEL_SHARP_2013", MagicKernelSharp2013Filter); | ||
+ IMAGICK_REGISTER_CONST_LONG("FILTER_MAGIC_KERNEL_SHARP_2021", MagicKernelSharp2021Filter); | ||
+#endif | ||
IMAGICK_REGISTER_CONST_LONG("IMGTYPE_UNDEFINED", UndefinedType); | ||
IMAGICK_REGISTER_CONST_LONG("IMGTYPE_BILEVEL", BilevelType); | ||
IMAGICK_REGISTER_CONST_LONG("IMGTYPE_GRAYSCALE", GrayscaleType); | ||
@@ -1284,12 +1307,17 @@ | ||
IMAGICK_REGISTER_CONST_LONG("COMPRESSION_DWAB", DWABCompression); | ||
#endif | ||
|
||
-#if MagickLibVersion >= 0x711 | ||
+#if MAGICK_LIB_VERSION_GTE(7, 1, 0, 13) | ||
// Technically >= 7.1.0-13 but we still don't have a mechanism for | ||
// detecting patch versions. | ||
IMAGICK_REGISTER_CONST_LONG("COMPRESSION_BC7", BC7Compression); | ||
#endif | ||
|
||
+// ImageMagick version >= 7.1.1-16 | ||
+#if MAGICK_LIB_VERSION_GTE(7, 1, 1, 16) | ||
+ IMAGICK_REGISTER_CONST_LONG("COMPRESSION_LERC", LERCCompression); | ||
+#endif | ||
+ | ||
IMAGICK_REGISTER_CONST_LONG("PAINT_POINT", PointMethod); | ||
IMAGICK_REGISTER_CONST_LONG("PAINT_REPLACE", ReplaceMethod); | ||
IMAGICK_REGISTER_CONST_LONG("PAINT_FLOODFILL", FloodfillMethod); | ||
@@ -1552,6 +1580,11 @@ | ||
IMAGICK_REGISTER_CONST_LONG("COLORSPACE_JZAZBZ", JzazbzColorspace); | ||
#endif | ||
|
||
+#if MAGICK_LIB_VERSION_GTE(7, 1, 1, 9) | ||
+ IMAGICK_REGISTER_CONST_LONG("COLORSPACE_OKLAB", OklabColorspace); | ||
+ IMAGICK_REGISTER_CONST_LONG("COLORSPACE_OKLCH", OklchColorspace); | ||
+#endif | ||
+ | ||
IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_UNDEFINED", UndefinedVirtualPixelMethod); | ||
IMAGICK_REGISTER_CONST_LONG("VIRTUALPIXELMETHOD_BACKGROUND", BackgroundVirtualPixelMethod); | ||
#if MagickLibVersion < 0x700 | ||
@@ -1801,6 +1834,9 @@ | ||
#if MagickLibVersion >= 0x700 | ||
IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_OFF", OffAlphaChannel); | ||
#endif | ||
+#if MAGICK_LIB_VERSION_GTE(7, 1, 1, 26) | ||
+ IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_OFF_IF_OPAQUE", OffIfOpaqueAlphaChannel); | ||
+#endif | ||
IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_OPAQUE", OpaqueAlphaChannel); | ||
IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_SHAPE", ShapeAlphaChannel); | ||
IMAGICK_REGISTER_CONST_LONG("ALPHACHANNEL_TRANSPARENT", TransparentAlphaChannel); | ||
@@ -1948,6 +1984,10 @@ | ||
IMAGICK_REGISTER_CONST_LONG("DIRECTION_LEFT_TO_RIGHT", LeftToRightDirection); | ||
IMAGICK_REGISTER_CONST_LONG("DIRECTION_RIGHT_TO_LEFT", RightToLeftDirection); | ||
|
||
+#if MAGICK_LIB_VERSION_GTE(7, 1, 1, 14) | ||
+ IMAGICK_REGISTER_CONST_LONG("DIRECTION_TOP_TO_BOTTOM", TopToBottomDirection); | ||
+#endif | ||
+ | ||
// The kernel is scaled directly using given scaling factor without change. | ||
IMAGICK_REGISTER_CONST_LONG("NORMALIZE_KERNEL_NONE", 0); | ||
// Kernel normalization ('normalize_flags' given) is designed to ensure | ||
diff -u -r ../imagick-3.7.0/tests/316_Imagick_getImageKurtosis.phpt ./tests/316_Imagick_getImageKurtosis.phpt | ||
--- ../imagick-3.7.0/tests/316_Imagick_getImageKurtosis.phpt 2022-01-11 14:53:27.000000000 +0000 | ||
+++ ./tests/316_Imagick_getImageKurtosis.phpt 2025-01-10 16:44:16.803405613 +0000 | ||
@@ -14,8 +14,19 @@ | ||
$imagick = new \Imagick(__DIR__ . '/Biter_500.jpg'); | ||
$values = $imagick->getImageKurtosis(); | ||
|
||
- check_value($values, "kurtosis", -0.9379261035010518); | ||
- check_value($values, "skewness", 0.4562517200972045); | ||
+ try { | ||
+ check_value($values, "kurtosis", -0.9379261035010518); | ||
+ } catch (\Exception $exception) { | ||
+ // From version 7.1.1-24 the value of kurtosis is -0.7092599567492 | ||
+ check_value($values, "kurtosis", -0.7092599567492); | ||
+ } | ||
+ | ||
+ try { | ||
+ check_value($values, "skewness", 0.4562517200972045); | ||
+ } catch (\Exception $exception) { | ||
+ // From version 7.1.1-24 the value of skewness is 0.56839010636614 | ||
+ check_value($values, "skewness", 0.56839010636614); | ||
+ } | ||
} | ||
|
||
getImageKurtosis() ; | ||
diff -u -r ../imagick-3.7.0/util/calculate_cflags.php ./util/calculate_cflags.php | ||
--- ../imagick-3.7.0/util/calculate_cflags.php 2022-01-11 14:53:27.000000000 +0000 | ||
+++ ./util/calculate_cflags.php 2025-01-10 16:44:16.803405613 +0000 | ||
@@ -58,6 +58,14 @@ | ||
); | ||
} | ||
|
||
-$result = implode(" ", $CFLAGS); | ||
+// Problem with zend_*.h files on newer PHP builds | ||
+if (in_array($PHP_VERSION, ['8.2', '8.3', '8.4'], true)) { | ||
+ $CFLAGS = array_values(array_diff($CFLAGS, ['-Wdeclaration-after-statement'])); | ||
+} | ||
+if (in_array($PHP_VERSION, ['8.4'], true)) { | ||
+ $CFLAGS[] = "-Wno-missing-field-initializers"; | ||
+} | ||
+ | ||
+$result = implode(" ", array_unique($CFLAGS)); | ||
echo $result; | ||
fwrite(STDERR, "Ok. CFLAGS are: $result\n"); | ||
diff -u -r ../imagick-3.7.0/util/check_for_missing_enums.php ./util/check_for_missing_enums.php | ||
--- ../imagick-3.7.0/util/check_for_missing_enums.php 2022-01-11 14:53:27.000000000 +0000 | ||
+++ ./util/check_for_missing_enums.php 2025-01-10 16:44:16.803405613 +0000 | ||
@@ -158,6 +158,9 @@ | ||
'MagickCore/cache-view.h' => [ | ||
'VirtualPixelMethod', | ||
], | ||
+ 'MagickCore/channel.h' => [ | ||
+ 'AlphaChannelOption', | ||
+ ], | ||
'MagickCore/compare.h' => [ | ||
'MetricType', | ||
], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ TERMUX_PKG_LICENSE="PHP-3.01" | |
TERMUX_PKG_LICENSE_FILE=LICENSE | ||
TERMUX_PKG_MAINTAINER="ian4hu <[email protected]>" | ||
TERMUX_PKG_VERSION=3.7.0 | ||
TERMUX_PKG_REVISION=5 | ||
TERMUX_PKG_REVISION=6 | ||
TERMUX_PKG_SRCURL=https://github.com/Imagick/imagick/archive/refs/tags/${TERMUX_PKG_VERSION}.tar.gz | ||
TERMUX_PKG_SHA256=aa2e311efb7348350c7332876252720af6fb71210d13268de765bc41f51128f9 | ||
TERMUX_PKG_DEPENDS="php, imagemagick" | ||
|