-
-
Save cmb69/d2d0339e4c33eab9e8f536c81c5274d4 to your computer and use it in GitHub Desktop.
GD with AVIF on Windows
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
ext/gd/config.w32 | 11 ++++++++++- | |
1 file changed, 10 insertions(+), 1 deletion(-) | |
diff --git a/ext/gd/config.w32 b/ext/gd/config.w32 | |
index 541d5f51e0..8ed0205287 100644 | |
--- a/ext/gd/config.w32 | |
+++ b/ext/gd/config.w32 | |
@@ -2,6 +2,7 @@ | |
ARG_WITH("gd", "Bundled GD support", "yes,shared"); | |
ARG_WITH("libwebp", "webp support", "yes"); | |
+ARG_WITH("libavif", "avif support", "yes"); | |
if (PHP_GD != "no") { | |
if ( | |
@@ -30,6 +31,14 @@ if (PHP_GD != "no") { | |
WARNING("libwebp not enabled; libraries and headers not found"); | |
} | |
} | |
+ if (PHP_LIBAVIF != "no") { | |
+ if (CHECK_LIB("avif.lib", "gd", PHP_GD) && | |
+ CHECK_HEADER_ADD_INCLUDE("avif.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\avif")) { | |
+ ADD_FLAG("CFLAGS_GD", "/D HAVE_LIBAVIF /D HAVE_GD_AVIF"); | |
+ } else { | |
+ WARNING("libavif not enabled; libraries and headers not found"); | |
+ } | |
+ } | |
CHECK_LIB("User32.lib", "gd", PHP_GD); | |
CHECK_LIB("Gdi32.lib", "gd", PHP_GD); | |
@@ -39,7 +48,7 @@ if (PHP_GD != "no") { | |
gdft.c gd_gd2.c gd_gd.c gd_gif_in.c gd_gif_out.c gdhelpers.c gd_io.c gd_io_dp.c \ | |
gd_io_file.c gd_io_ss.c gd_jpeg.c gdkanji.c gd_png.c gd_ss.c \ | |
gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c gd_xbm.c gd_security.c gd_transform.c \ | |
- gd_filter.c gd_pixelate.c gd_rotate.c gd_color_match.c gd_webp.c \ | |
+ gd_filter.c gd_pixelate.c gd_rotate.c gd_color_match.c gd_webp.c gd_avif.c \ | |
gd_crop.c gd_interpolation.c gd_matrix.c gd_bmp.c gd_tga.c", "gd"); | |
AC_DEFINE('HAVE_LIBGD', 1, 'GD support'); | |
ADD_FLAG("CFLAGS_GD", " \ |
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
This requires libavif builds from https://github.com/winlibs/libavif/actions/runs/843457552. | |
The x86 build is broken, but x64 should work. | |
Based on https://github.com/morsssss/php-src/tree/avif; | |
the .diff needs to be applied on top. |
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
<?php | |
$im = imagecreatefromjpeg("https://windows.php.net/images/header-logo-win.jpg"); | |
imageavif($im, __DIR__ ."/avif.avif"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment