From cc3e6f368fe73dc0b7784e11b083dd240261de7d Mon Sep 17 00:00:00 2001 From: Yavor Doganov Date: Wed, 31 Dec 2025 08:06:06 +0200 Subject: [PATCH] NS: Add native image support for HEIF, SVG and WEBP on GNUstep * src/nsimage.m (ns_can_use_native_image_api): Handle HEIF, SVG and WEBP image types on GNUstep. * src/image.c (syms_of_image): Add conditional native image support for HEIF, SVG and WEBP on GNUstep. (Bug#80101) --- src/image.c | 26 +++++++++++++++++++++----- src/nsimage.m | 10 ++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/image.c b/src/image.c index ac6e76f10a7..71a091ea498 100644 --- a/src/image.c +++ b/src/image.c @@ -13054,11 +13054,18 @@ non-numeric, there is no explicit limit on the size of images. */); #if defined (HAVE_WEBP) \ || (defined (HAVE_NATIVE_IMAGE_API) \ - && ((defined (HAVE_NS) && defined (NS_IMPL_COCOA)) \ - || defined (HAVE_HAIKU))) + && (defined (HAVE_NS) || defined (HAVE_HAIKU))) DEFSYM (Qwebp, "webp"); DEFSYM (Qwebpdemux, "webpdemux"); +#if !defined (NS_IMPL_GNUSTEP) || defined (HAVE_WEBP) add_image_type (Qwebp); +#else + + /* On GNUstep, WEBP support is provided via ImageMagick only if + gnustep-gui is built with --enable-imagemagick. */ + if (image_can_use_native_api (Qwebp)) + add_image_type (Qwebp); +#endif /* NS_IMPL_GNUSTEP && !HAVE_WEBP */ #endif #if defined (HAVE_IMAGEMAGICK) @@ -13081,18 +13088,27 @@ non-numeric, there is no explicit limit on the size of images. */); DEFSYM (Qgobject, "gobject"); #endif /* HAVE_NTGUI */ #elif defined HAVE_NATIVE_IMAGE_API \ - && ((defined HAVE_NS && defined NS_IMPL_COCOA) \ - || defined HAVE_HAIKU) + && (defined HAVE_NS || defined HAVE_HAIKU) DEFSYM (Qsvg, "svg"); - /* On Haiku, the SVG translator may not be installed. */ + /* On Haiku, the SVG translator may not be installed. On GNUstep, SVG + support is provided by ImageMagick so not guaranteed. Furthermore, + some distros (e.g., Debian) ship ImageMagick's SVG module in a + separate binary package which may not be installed. */ if (image_can_use_native_api (Qsvg)) add_image_type (Qsvg); #endif #ifdef HAVE_NS DEFSYM (Qheic, "heic"); +#ifdef NS_IMPL_COCOA add_image_type (Qheic); +#else + + /* HEIC support in gnustep-gui is provided by ImageMagick. */ + if (image_can_use_native_api (Qheic)) + add_image_type (Qheic); +#endif /* NS_IMPL_GNUSTEP */ #endif #if HAVE_NATIVE_IMAGE_API diff --git a/src/nsimage.m b/src/nsimage.m index 3c318c37cfd..426ce20eb05 100644 --- a/src/nsimage.m +++ b/src/nsimage.m @@ -102,6 +102,16 @@ ns_can_use_native_image_api (Lisp_Object type) imageType = @"gif"; else if (EQ (type, Qtiff)) imageType = @"tiff"; +#ifndef HAVE_RSVG + else if (EQ (type, Qsvg)) + imageType = @"svg"; +#endif +#ifndef HAVE_WEBP + else if (EQ (type, Qwebp)) + imageType = @"webp"; +#endif + else if (EQ (type, Qheic)) + imageType = @"heic"; types = [NSImage imageFileTypes]; #endif