all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#51296: [PATCH] Add WebP format support
@ 2021-10-19 23:27 Stefan Kangas
  2021-10-20  8:42 ` Lars Ingebrigtsen
  2021-10-20 13:02 ` Stefan Kangas
  0 siblings, 2 replies; 21+ messages in thread
From: Stefan Kangas @ 2021-10-19 23:27 UTC (permalink / raw)
  To: 51296

[-- Attachment #1: Type: text/plain, Size: 882 bytes --]

Severity: wishlist

WebP is an image format promoted by Google since 2010 with a promise of
decreased file sizes.  Adoption in web browsers have been slow, but in
2019, Firefox added support for it, and other browsers followed.[1]
Since then, this image format has become increasingly common on the web,
and is reported to be used on 2.5 % of all websites.[2]

I think it's important for Emacs to support it, both to support general
web development and to display images properly in e.g. EWW.  Given that
we no longer promote ImageMagick, I think adding our own support for it
is the way to go.

The attached patch does that, by using libwebp where it is available.[3]

Reviews are welcome, as usual.

Footnotes:
[1]  https://bugzilla.mozilla.org/show_bug.cgi?id=1294490

[2]  https://w3techs.com/technologies/details/im-webp

[3]  https://developers.google.com/speed/webp/download

[-- Attachment #2: 0001-Add-WebP-format-support.patch --]
[-- Type: text/x-diff, Size: 39381 bytes --]

From 33f21cb15b9f5c2b7724995efc6eff6009525397 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefan@marxist.se>
Date: Fri, 15 Oct 2021 05:25:39 +0200
Subject: [PATCH] Add WebP format support

* configure.ac (--with-webp): New option.
(HAVE_WEBP): New variable.
* src/image.c (enum webp_keyword_index) [HAVE_WEBP]: New enum.
(webp_format) [HAVE_WEBP]: New variable.
(webp_image_p, init_webp_functions, webp_load) [HAVE_WEBP]: New
functions for WebP support.
(image_types) [HAVE_WEBP]: Define WebP format.
(syms_of_image) <Qwebp> [HAVE_WEBP]: New DEFSYM.  Add image type Qwebp.
* src/Makefile.in (LIBIMAGE): Add WEBP_LIBS.

* lisp/files.el (auto-mode-alist):
* lisp/image-file.el (image-file-name-extensions):
* lisp/image.el (image-type-header-regexps)
(image-type-file-name-regexps, image-type-auto-detectable): Add WebP
support.

* INSTALL:
* admin/CPP-DEFINES:
* doc/lispref/display.texi (Image Formats, Other Image Types):
* nt/INSTALL: Document WebP support.

* test/lisp/image-tests.el (image-find-image)
(image-type-from-file-name): Expand tests.
* test/src/image-tests.el (image-tests--files): Add WebP.
(image-tests-image-size/webp, image-tests-image-mask-p/webp)
(image-tests-image-metadata/webp): New tests.
* test/data/image/black.webp: New file.
---
 INSTALL                    |   2 +
 admin/CPP-DEFINES          |   1 +
 configure.ac               |  19 +++
 doc/lispref/display.texi   |  11 +-
 lisp/files.el              |   1 +
 lisp/image-file.el         |   2 +-
 lisp/image.el              |   3 +
 nt/INSTALL                 |   9 +-
 src/Makefile.in            |   2 +-
 src/image.c                | 285 +++++++++++++++++++++++++++++++++++++
 test/data/image/black.webp | Bin 0 -> 37780 bytes
 test/lisp/image-tests.el   |   8 +-
 test/src/image-tests.el    |  23 ++-
 13 files changed, 353 insertions(+), 13 deletions(-)
 create mode 100644 test/data/image/black.webp

diff --git a/INSTALL b/INSTALL
index 6207f43cec..21298422af 100644
--- a/INSTALL
+++ b/INSTALL
@@ -187,6 +187,7 @@ X11 is being used.
   X libtiff for TIFF: http://www.simplesystems.org/libtiff/
   X libgif for GIF:   http://giflib.sourceforge.net/
     librsvg2 for SVG: https://wiki.gnome.org/Projects/LibRsvg
+    libwebp for WebP: https://developers.google.com/speed/webp/
 
 If you supply the appropriate --without-LIB option, 'configure' will
 omit the corresponding library from Emacs, even if that makes for a
@@ -313,6 +314,7 @@ or more of these options:
   --without-gif          for GIF image support
   --without-png          for PNG image support
   --without-rsvg         for SVG image support
+  --without-webp         for WebP image support
 
 Although ImageMagick support is disabled by default due to security
 and stability concerns, you can enable it with --with-imagemagick.
diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES
index 68c12438f5..634d6f3f3b 100644
--- a/admin/CPP-DEFINES
+++ b/admin/CPP-DEFINES
@@ -287,6 +287,7 @@ HAVE_UTIMENSAT
 HAVE_UTMP_H
 HAVE_VFORK
 HAVE_VFORK_H
+HAVE_WEBP
 HAVE_WCHAR_H
 HAVE_WCHAR_T
 HAVE_WINDOW_SYSTEM
diff --git a/configure.ac b/configure.ac
index 9ab0314428..17ac106d84 100644
--- a/configure.ac
+++ b/configure.ac
@@ -447,6 +447,7 @@ AC_DEFUN
 OPTION_DEFAULT_ON([gif],[don't compile with GIF image support])
 OPTION_DEFAULT_ON([png],[don't compile with PNG image support])
 OPTION_DEFAULT_ON([rsvg],[don't compile with SVG image support])
+OPTION_DEFAULT_ON([webp],[don't compile with WebP image support])
 OPTION_DEFAULT_ON([lcms2],[don't compile with Little CMS support])
 OPTION_DEFAULT_ON([libsystemd],[don't compile with libsystemd support])
 OPTION_DEFAULT_ON([cairo],[don't compile with Cairo drawing])
@@ -2588,6 +2589,23 @@ AC_DEFUN
   fi
 fi
 
+HAVE_WEBP=no
+if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${opsys}" = "mingw32"; then
+   if test "${with_webp}" != "no"; then
+      WEBP_REQUIRED=0.6.0
+      WEBP_MODULE="libwebp >= $WEBP_REQUIRED"
+
+      EMACS_CHECK_MODULES([WEBP], [$WEBP_MODULE])
+      AC_SUBST(WEBP_CFLAGS)
+      AC_SUBST(WEBP_LIBS)
+
+      if test $HAVE_WEBP = yes; then
+        AC_DEFINE(HAVE_WEBP, 1, [Define to 1 if using libwebp.])
+        CFLAGS="$CFLAGS $WEBP_CFLAGS"
+      fi
+   fi
+fi
+
 HAVE_IMAGEMAGICK=no
 if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${HAVE_W32}" = "yes"; then
   if test "${with_imagemagick}" != "no"; then
@@ -5928,6 +5946,7 @@ AC_DEFUN
   Does Emacs use a gif library?                           ${HAVE_GIF} $LIBGIF
   Does Emacs use a png library?                           ${HAVE_PNG} $LIBPNG
   Does Emacs use -lrsvg-2?                                ${HAVE_RSVG}
+  Does Emacs use -lwebp?                                  ${HAVE_WEBP}
   Does Emacs use cairo?                                   ${HAVE_CAIRO}
   Does Emacs use -llcms2?                                 ${HAVE_LCMS2}
   Does Emacs use imagemagick?                             ${HAVE_IMAGEMAGICK}
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 16577d13c1..9c378a3027 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -5264,13 +5264,13 @@ Image Formats
   Supported image formats (and the required support libraries) include
 PBM and XBM (which do not depend on support libraries and are always
 available), XPM (@code{libXpm}), GIF (@code{libgif} or
-@code{libungif}), JPEG (@code{libjpeg}), TIFF
-(@code{libtiff}), PNG (@code{libpng}), and SVG (@code{librsvg}).
+@code{libungif}), JPEG (@code{libjpeg}), TIFF (@code{libtiff}), PNG
+(@code{libpng}), SVG (@code{librsvg}), and WebP (@code{libwebp}).
 
   Each of these image formats is associated with an @dfn{image type
 symbol}.  The symbols for the above formats are, respectively,
-@code{pbm}, @code{xbm}, @code{xpm}, @code{gif},
-@code{jpeg}, @code{tiff}, @code{png}, and @code{svg}.
+@code{pbm}, @code{xbm}, @code{xpm}, @code{gif}, @code{jpeg},
+@code{tiff}, @code{png}, @code{svg}, and @code{webp}.
 
   Furthermore, if you build Emacs with ImageMagick
 (@code{libMagickWand}) support, Emacs can display any image format
@@ -6274,6 +6274,9 @@ Other Image Types
 @item TIFF
 Image type @code{tiff}.
 Supports the @code{:index} property.  @xref{Multi-Frame Images}.
+
+@item WebP
+Image type @code{webp}.
 @end table
 
 @node Defining Images
diff --git a/lisp/files.el b/lisp/files.el
index 5a6a33721b..e6b94a4a1a 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2758,6 +2758,7 @@ auto-mode-alist
      ("\\.gif\\'" . image-mode)
      ("\\.png\\'" . image-mode)
      ("\\.jpe?g\\'" . image-mode)
+     ("\\.webp\\'" . image-mode)
      ("\\.te?xt\\'" . text-mode)
      ("\\.[tT]e[xX]\\'" . tex-mode)
      ("\\.ins\\'" . tex-mode)		;Installation files for TeX packages.
diff --git a/lisp/image-file.el b/lisp/image-file.el
index fbc9eaaf94..6df43f737d 100644
--- a/lisp/image-file.el
+++ b/lisp/image-file.el
@@ -37,7 +37,7 @@
 
 ;;;###autoload
 (defcustom image-file-name-extensions
-  (purecopy '("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm" "xpm" "pbm" "pgm" "ppm" "pnm" "svg"))
+  (purecopy '("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm" "xpm" "pbm" "pgm" "ppm" "pnm" "svg" "webp"))
   "A list of image-file filename extensions.
 Filenames having one of these extensions are considered image files,
 in addition to those matching `image-file-name-regexps'.
diff --git a/lisp/image.el b/lisp/image.el
index 2022b41d1f..5343e26d03 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -48,6 +48,7 @@ image-type-header-regexps
     ("\\`\\(?:MM\0\\*\\|II\\*\0\\)" . tiff)
     ("\\`[\t\n\r ]*%!PS" . postscript)
     ("\\`\xff\xd8" . jpeg)    ; used to be (image-jpeg-p . jpeg)
+    ("\\`RIFF....WEBPVP8" . webp)
     (,(let* ((incomment-re "\\(?:[^-]\\|-[^-]\\)")
 	     (comment-re (concat "\\(?:!--" incomment-re "*-->[ \t\r\n]*<\\)")))
 	(concat "\\(?:<\\?xml[ \t\r\n]+[^>]*>\\)?[ \t\r\n]*<"
@@ -67,6 +68,7 @@ image-type-file-name-regexps
   '(("\\.png\\'" . png)
     ("\\.gif\\'" . gif)
     ("\\.jpe?g\\'" . jpeg)
+    ("\\.webp\\'" . webp)
     ("\\.bmp\\'" . bmp)
     ("\\.xpm\\'" . xpm)
     ("\\.pbm\\'" . pbm)
@@ -92,6 +94,7 @@ image-type-auto-detectable
     (jpeg . maybe)
     (tiff . maybe)
     (svg . maybe)
+    (webp . maybe)
     (postscript . nil))
   "Alist of (IMAGE-TYPE . AUTODETECT) pairs used to auto-detect image files.
 \(See `image-type-auto-detected-p').
diff --git a/nt/INSTALL b/nt/INSTALL
index 9f543151a9..a39057c66c 100644
--- a/nt/INSTALL
+++ b/nt/INSTALL
@@ -488,6 +488,7 @@ build will run on Windows 9X and newer systems).
        Does Emacs use a gif library?                           yes
        Does Emacs use a png library?                           yes
        Does Emacs use -lrsvg-2?                                yes
+       Does Emacs use -lwebp?                                  yes
        Does Emacs use cairo?                                   no
        Does Emacs use -llcms2?                                 yes
        Does Emacs use imagemagick?                             no
@@ -597,8 +598,8 @@ build will run on Windows 9X and newer systems).
 * Optional image library support
 
   In addition to its "native" image formats (pbm and xbm), Emacs can
-  handle other image types: xpm, tiff, gif, png, jpeg and experimental
-  support for svg.
+  handle other image types: xpm, tiff, gif, png, jpeg, webp and
+  experimental support for svg.
 
   To build Emacs with support for them, the corresponding headers must
   be in the include path and libraries should be where the linker
@@ -736,6 +737,10 @@ build will run on Windows 9X and newer systems).
   without it by specifying the --without-rsvg switch to the configure
   script.
 
+  For WebP images you will need libwebp:
+
+    https://developers.google.com/speed/webp/
+
   Binaries for the other image libraries can be found on the
   ezwinports site or at the GnuWin32 project (the latter are generally
   very old, so not recommended).  Note specifically that, due to some
diff --git a/src/Makefile.in b/src/Makefile.in
index 6d75e3537a..7c977e34ea 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -124,7 +124,7 @@ LIB_MATH=
 ## -lpthread, or empty.
 LIB_PTHREAD=@LIB_PTHREAD@
 
-LIBIMAGE=@LIBTIFF@ @LIBJPEG@ @LIBPNG@ @LIBGIF@ @LIBXPM@
+LIBIMAGE=@LIBTIFF@ @LIBJPEG@ @LIBPNG@ @LIBGIF@ @LIBXPM@ @WEBP_LIBS@
 
 XCB_LIBS=@XCB_LIBS@
 XFT_LIBS=@XFT_LIBS@
diff --git a/src/image.c b/src/image.c
index ff05741b2c..6ff172504f 100644
--- a/src/image.c
+++ b/src/image.c
@@ -8739,8 +8739,284 @@ gif_load (struct frame *f, struct image *img)
 #endif /* HAVE_GIF */
 
 
+#ifdef HAVE_WEBP
+
+\f
+/***********************************************************************
+				 WebP
+ ***********************************************************************/
+
+#include "webp/decode.h"
+
+/* Indices of image specification fields in webp_format, below.  */
+
+enum webp_keyword_index
+{
+  WEBP_TYPE,
+  WEBP_DATA,
+  WEBP_FILE,
+  WEBP_ASCENT,
+  WEBP_MARGIN,
+  WEBP_RELIEF,
+  WEBP_ALGORITHM,
+  WEBP_HEURISTIC_MASK,
+  WEBP_MASK,
+  WEBP_BACKGROUND,
+  WEBP_LAST
+};
+
+/* Vector of image_keyword structures describing the format
+   of valid user-defined image specifications.  */
+
+static const struct image_keyword webp_format[WEBP_LAST] =
+{
+  {":type",		IMAGE_SYMBOL_VALUE,			1},
+  {":data",		IMAGE_STRING_VALUE,			0},
+  {":file",		IMAGE_STRING_VALUE,			0},
+  {":ascent",		IMAGE_ASCENT_VALUE,			0},
+  {":margin",		IMAGE_NON_NEGATIVE_INTEGER_VALUE_OR_PAIR, 0},
+  {":relief",		IMAGE_INTEGER_VALUE,			0},
+  {":conversion",	IMAGE_DONT_CHECK_VALUE_TYPE,		0},
+  {":heuristic-mask",	IMAGE_DONT_CHECK_VALUE_TYPE,		0},
+  {":mask",		IMAGE_DONT_CHECK_VALUE_TYPE,		0},
+  {":background",	IMAGE_STRING_OR_NIL_VALUE,		0}
+};
+
+/* Return true if OBJECT is a valid WebP image specification.  */
+
+static bool
+webp_image_p (Lisp_Object object)
+{
+  struct image_keyword fmt[WEBP_LAST];
+  memcpy (fmt, webp_format, sizeof fmt);
+
+  if (!parse_image_spec (object, fmt, WEBP_LAST, Qwebp))
+    return false;
+
+  /* Must specify either the :data or :file keyword.  */
+  return fmt[WEBP_FILE].count + fmt[WEBP_DATA].count == 1;
+}
+
+#ifdef WINDOWSNT
+
+/* WebP library details.  */
+
+DEF_DLL_FN (int, WebPGetInfo, (const uint8_t* data, size_t data_size, int* width, int* height));
+DEF_DLL_FN (VP8StatusCode, WebPGetFeatures,
+	    (const uint8_t* data, size_t data_size, WebPBitstreamFeatures* features));
+DEF_DLL_FN (uint8_t*, WebPDecodeRGB,
+	    (const uint8_t* data, size_t data_size, int* width, int* height));
+DEF_DLL_FN (uint8_t*, WebPDecodeBGR,
+	    (const uint8_t* data, size_t data_size, int* width, int* height));
+DEF_DLL_FN (void, WebPFreeDecBuffer
+	    (WebPDecBuffer* buffer));
+
+static bool
+init_webp_functions (void)
+{
+  HMODULE library;
+
+  if (!(library = w32_delayed_load (Qwebp)))
+    return 0;
+
+  LOAD_DLL_FN (library, WebPGetInfo);
+  LOAD_DLL_FN (library, WebPGetFeatures);
+  LOAD_DLL_FN (library, WebPDecodeRGBA);
+  LOAD_DLL_FN (library, WebPDecodeRGB);
+  LOAD_DLL_FN (library, WebPFree);
+  return true;
+}
+
+#undef WebPGetInfo
+#undef WebPGetFeatures
+#undef WebPDecodeRGBA
+#undef WebPDecodeRGB
+#undef WebPFree
+
+#define WebPGetInfo fn_WebPGetInfo
+#define WebPGetFeatures fn_WebPGetFeatures
+#define WebPDecodeRGBA fn_WebPDecodeRGBA
+#define WebPDecodeRGB fn_WebPDecodeRGB
+#define WebPFree fn_WebPFree
+
+#endif /* WINDOWSNT */
+
+/* Load WebP image IMG for use on frame F.  Value is true if
+   successful.  */
+
+static bool
+webp_load (struct frame *f, struct image *img)
+{
+  ptrdiff_t size = 0;
+  uint8_t *contents;
+  Lisp_Object file;
+
+  /* Open the WebP file.  */
+  Lisp_Object specified_file = image_spec_value (img->spec, QCfile, NULL);
+  Lisp_Object specified_data = image_spec_value (img->spec, QCdata, NULL);
+
+  if (NILP (specified_data))
+    {
+      int fd;
+      file = image_find_image_fd (specified_file, &fd);
+      if (!STRINGP (file))
+	{
+	  image_error ("Cannot find image file `%s'", specified_file);
+	  return false;
+	}
+
+      contents = (uint8_t *) slurp_file (fd, &size);
+      if (contents == NULL)
+	{
+	  image_error ("Error loading WebP image `%s'", file);
+	  return false;
+	}
+    }
+  else
+    {
+      if (!STRINGP (specified_data))
+	{
+	  image_error ("Invalid image data `%s'", specified_data);
+	  return false;
+	}
+      contents = (uint8_t*) SSDATA (specified_data);
+      size = SBYTES (specified_data);
+    }
+
+  /* Validate the WebP image header.  */
+  if (!WebPGetInfo (contents, size, NULL, NULL))
+    {
+      if (!NILP (specified_data))
+	image_error ("Not a WebP file: `%s'", file);
+      else
+	image_error ("Invalid WebP data");
+      goto webp_error1;
+    }
+
+  /* Get WebP features.  */
+  WebPBitstreamFeatures features;
+  VP8StatusCode result = WebPGetFeatures (contents, size, &features);
+  switch (result)
+    {
+    case VP8_STATUS_OK:
+      break;
+    case VP8_STATUS_NOT_ENOUGH_DATA:
+    case VP8_STATUS_OUT_OF_MEMORY:
+    case VP8_STATUS_INVALID_PARAM:
+    case VP8_STATUS_BITSTREAM_ERROR:
+    case VP8_STATUS_UNSUPPORTED_FEATURE:
+    case VP8_STATUS_SUSPENDED:
+    case VP8_STATUS_USER_ABORT:
+    default:
+      /* Error out in all other cases.  */
+      if (!NILP (specified_data))
+	image_error ("Error when interpreting WebP data: `%s'", file);
+      else
+	image_error ("Error when interpreting WebP data");
+      goto webp_error1;
+    }
+
+  /* Decode WebP data.  */
+  uint8_t *decoded;
+  int width, height;
+  if (features.has_alpha)
+    /* Linear [r0, g0, b0, a0, r1, g1, b1, a1, ...] order.  */
+    decoded = WebPDecodeRGBA (contents, size, &width, &height);
+  else
+    /* Linear [r0, g0, b0, r1, g1, b1, ...] order.  */
+    decoded = WebPDecodeRGB (contents, size, &width, &height);
+
+  if (!(width <= INT_MAX && height <= INT_MAX
+	&& check_image_size (f, width, height)))
+    {
+      image_size_error ();
+      goto webp_error2;
+    }
+
+  /* Create the x image and pixmap.  */
+  Emacs_Pix_Container ximg, mask_img;
+  if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, false))
+    goto webp_error2;
+
+  /* Create an image and pixmap serving as mask if the WebP image
+     contains an alpha channel.  */
+  if (features.has_alpha
+      && !image_create_x_image_and_pixmap (f, img, width, height, 1, &mask_img, true))
+    {
+      image_destroy_x_image (ximg);
+      image_clear_image_1 (f, img, CLEAR_IMAGE_PIXMAP);
+      goto webp_error2;
+    }
+
+  /* Fill the X image and mask from WebP data.  */
+  init_color_table ();
+
+  uint8_t *p = decoded;
+  for (int y = 0; y < height; ++y)
+    {
+      for (int x = 0; x < width; ++x)
+	{
+	  int r = *p++ << 8;
+	  int g = *p++ << 8;
+	  int b = *p++ << 8;
+	  PUT_PIXEL (ximg, x, y, lookup_rgb_color (f, r, g, b));
+
+	  /* An alpha channel associates variable transparency with an
+	     image.  WebP allows up to 256 levels of partial transparency.
+	     We handle this like with PNG (which see), using the frame's
+	     background color to combine the image with.  */
+	  if (features.has_alpha)
+	    {
+	      if (mask_img)
+		PUT_PIXEL (mask_img, x, y, *p > 0 ? PIX_MASK_DRAW : PIX_MASK_RETAIN);
+	      ++p;
+	    }
+	}
+    }
+
+#ifdef COLOR_TABLE_SUPPORT
+  /* Remember colors allocated for this image.  */
+  img->colors = colors_in_color_table (&img->ncolors);
+  free_color_table ();
+#endif /* COLOR_TABLE_SUPPORT */
+
+  /* Put ximg into the image.  */
+  image_put_x_image (f, img, ximg, 0);
+
+  /* Same for the mask.  */
+  if (mask_img)
+    {
+      /* Fill in the background_transparent field while we have the
+	 mask handy.  Casting avoids a GCC warning.  */
+      image_background_transparent (img, f, (Emacs_Pix_Context)mask_img);
+
+      image_put_x_image (f, img, mask_img, 1);
+    }
+
+  img->width = width;
+  img->height = height;
+
+  /* Clean up.  */
+  WebPFree (decoded);
+  if (NILP (specified_data))
+    xfree (contents);
+  return true;
+
+ webp_error2:
+  WebPFree (decoded);
+
+ webp_error1:
+  if (NILP (specified_data))
+    xfree (contents);
+  return false;
+}
+
+#endif /* HAVE_WEBP */
+
+
 #ifdef HAVE_IMAGEMAGICK
 
+\f
 /***********************************************************************
 				 ImageMagick
 ***********************************************************************/
@@ -10725,6 +11001,10 @@ initialize_image_type (struct image_type const *type)
 #if defined HAVE_XPM || defined HAVE_NS
  { SYMBOL_INDEX (Qxpm), xpm_image_p, xpm_load, image_clear_image,
    IMAGE_TYPE_INIT (init_xpm_functions) },
+#endif
+#if defined HAVE_WEBP
+ { SYMBOL_INDEX (Qwebp), webp_image_p, webp_load, image_clear_image,
+   IMAGE_TYPE_INIT (init_webp_functions) },
 #endif
  { SYMBOL_INDEX (Qxbm), xbm_image_p, xbm_load, image_clear_image },
  { SYMBOL_INDEX (Qpbm), pbm_image_p, pbm_load, image_clear_image },
@@ -10891,6 +11171,11 @@ syms_of_image (void)
   add_image_type (Qpng);
 #endif
 
+#if defined (HAVE_WEBP)
+  DEFSYM (Qwebp, "webp");
+  add_image_type (Qwebp);
+#endif
+
 #if defined (HAVE_IMAGEMAGICK)
   DEFSYM (Qimagemagick, "imagemagick");
   add_image_type (Qimagemagick);
diff --git a/test/data/image/black.webp b/test/data/image/black.webp
new file mode 100644
index 0000000000000000000000000000000000000000..5dbe716415b16e6111ac92ec3978411d95be08e3
GIT binary patch
literal 37780
zcmeHw4|p5JnfJS+^=c$5_F7SdVq6%>iX)piksZfzTtZj2W8^deCviidluG`S$RV+f
z?ffC7bgd}HNz+sqH>4?0<ECj!IWAC2Im%Hd1PC;R@TZh=Juc9eqrHATuGj1J`W^B2
z8%a)-kaG9*yQg<g&%6F<-<^GD=AC!md1rQZcf7Kxv2phuMAs~-YhK-4v&K$DbAUFY
zr9@5j_06LUr^H4#v~BEDgG3v<`g>PiStr(9d!4ZUjO<iEGiVykkGA#ogqoX|N$v}8
zzkQVydFADDnbw7Q{$S{|_KrRXr3i2sZ9TpHpd+BGxAgZ&dLL+4TP)fR`hL)JdLba_
z*JOBWn*ODv*QMxGp<KN!E9+4<7sAE5EV?y|Zj1G91Wy%s{OudNkUm?JrrRZbi=;Ph
z*aX>9n=GNDqw8a<aP$L3bR{*>a%v_)t+a_cX#@3BIgVWj>7$jnUiSy$7pCGjBUUS7
zb)r%PHBdKgq-ZKW$vOZJwzInJTRXop6{I-oh;rVTnE2;eL{`-Cd&!B3|9kJm#Cu~z
zmLC(1cb$#jJxWybF9=Vb4fB7QC_h2;$g#6wt#=ZA`!*uak9wlL(NsP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U`D!Z-3|7vsG}8{PM~<nInrc>7K(msTY|)lvmr(
z-L^^Q)YP!pCk3o+?{4dCuT7C_+gmFZET{^WS1xR8FR$tVwP@km1?3&Vnu>~!it4sS
z3xbpBG<Eg$N4wfOWI9NBZYL61+a6uCU_txB@<sEj7M547UDQ_Ix=1F{z9=|<QB_6N
z+KT98{HuFAVcpRU+49JA+L2C8uzJyg){aHxH5CgWM>N`6UengGwmjHYGruAj4OUmR
zR{4a~cWtP-X|b<zF2qWmHgAabukG&LxY)O>vuo4VOlV8z#*S6}QK_Pe>iJdGHNlF7
z3#t~?EL>Qb;aJ_#+Xs7<NmT^rRwB5)t+o*fMPWdl8>8zw=56U{?ePhz_*%#g4MwGf
zBgIsSYU_JDqW#^yE#2K47W<?uLMA2KM8@E2mvy(LqNF%G+B5B~F1l_W$a#O5>-;OL
zV%=N1{)5<)Jd<%lz5QFddvCnD_v+U59c}%8AolyYCgZP!E9&d-y}9WRiG2=3+S0;^
z(cOD<Ca+Z;H)W^|og&pTYol#x4faJhceML5fo-v9*SZdPJG6o{TjvEVZGP*bg>4Ii
z!SY~mertJETkHJtXm$01@&&=F_JtkM>P6MT1(Wgny4Ut^iS~Ac)}hi+H!%8C-H1TS
zMoK67w!}J6otFhG@sIC(sXCF~D=oKd>}Wh^izGckZId*NRhxQxHgtCMo-Jo8?gbgn
z24>9V4@NqBJr$?EyXR&!m{|YSTe>cs)%!S7@s@SAb#(Q0Ur@NLYx87Dv-~#1N(G@a
ukmQ-Z<%$oui=MhPrGY68Ole?B15+B9(!igq2F~7{c64EowgvZ|^#1_XXWs|_

literal 0
HcmV?d00001

diff --git a/test/lisp/image-tests.el b/test/lisp/image-tests.el
index aa8600609c..c34c152cc9 100644
--- a/test/lisp/image-tests.el
+++ b/test/lisp/image-tests.el
@@ -49,12 +49,14 @@ image--set-property
     (should (equal image '(image)))))
 
 (ert-deftest image-find-image ()
-  (find-image '((:type xpm :file "undo.xpm")))
-  (find-image '((:type png :file "newsticker/rss-feed.png" :ascent center))))
+  (should (listp (find-image '((:type xpm :file "undo.xpm")))))
+  (should (listp (find-image '((:type png :file "newsticker/rss-feed.png" :ascent center)))))
+  (should-not (find-image '((:type png :file "does-not-exist-foo-bar.png")))))
 
 (ert-deftest image-type-from-file-name ()
   (should (eq (image-type-from-file-name "foo.jpg") 'jpeg))
-  (should (eq (image-type-from-file-name "foo.png") 'png)))
+  (should (eq (image-type-from-file-name "foo.png") 'png))
+  (should (eq (image-type-from-file-name "foo.webp") 'webp)))
 
 (ert-deftest image-type/from-filename ()
   ;; On emba, `image-types' and `image-load-path' do not exist.
diff --git a/test/src/image-tests.el b/test/src/image-tests.el
index d5e3a7cc5c..b921739a05 100644
--- a/test/src/image-tests.el
+++ b/test/src/image-tests.el
@@ -44,6 +44,8 @@ image-tests--files
     (tiff . ,(expand-file-name
               "nextstep/GNUstep/Emacs.base/Resources/emacs.tiff"
               source-directory))
+    (webp . ,(expand-file-name "test/data/image/black.webp"
+                               source-directory))
     (xbm . ,(find-image '((:file "gnus/gnus.xbm" :type xbm))))
     (xpm . ,(find-image '((:file "splash.xpm" :type xpm))))
     ;; TODO: gif
@@ -86,6 +88,13 @@ image-tests-image-size/tiff
      (should (floatp a))
      (should (floatp b)))))
 
+(ert-deftest image-tests-image-size/webp ()
+  (image-skip-unless 'webp)
+  (pcase (image-size (create-image (cdr (assq 'webp image-tests--files))))
+    (`(,a . ,b)
+     (should (floatp a))
+     (should (floatp b)))))
+
 (ert-deftest image-tests-image-size/xbm ()
   (image-skip-unless 'xbm)
   (pcase (image-size (cdr (assq 'xbm image-tests--files)))
@@ -130,7 +139,12 @@ image-tests-image-mask-p/svg
 (ert-deftest image-tests-image-mask-p/tiff ()
   (image-skip-unless 'tiff)
   (should-not (image-mask-p (create-image
-			     (cdr (assq 'tiff image-tests--files))))))
+                             (cdr (assq 'tiff image-tests--files))))))
+
+(ert-deftest image-tests-image-mask-p/webp ()
+  (image-skip-unless 'webp)
+  (should-not (image-mask-p (create-image
+                             (cdr (assq 'webp image-tests--files))))))
 
 (ert-deftest image-tests-image-mask-p/xbm ()
   (image-skip-unless 'xbm)
@@ -173,7 +187,12 @@ image-tests-image-metadata/svg
 (ert-deftest image-tests-image-metadata/tiff ()
   (image-skip-unless 'tiff)
   (should-not (image-metadata
-	       (create-image (cdr (assq 'tiff image-tests--files))))))
+               (create-image (cdr (assq 'tiff image-tests--files))))))
+
+(ert-deftest image-tests-image-metadata/webp ()
+  (image-skip-unless 'webp)
+  (should-not (image-metadata
+               (create-image (cdr (assq 'webp image-tests--files))))))
 
 (ert-deftest image-tests-image-metadata/xbm ()
   (image-skip-unless 'xbm)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2021-10-22 14:27 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-19 23:27 bug#51296: [PATCH] Add WebP format support Stefan Kangas
2021-10-20  8:42 ` Lars Ingebrigtsen
2021-10-20 12:40   ` Stefan Kangas
2021-10-20 13:02 ` Stefan Kangas
2021-10-20 13:14   ` Eli Zaretskii
2021-10-20 15:22     ` Stefan Kangas
2021-10-20 16:35       ` Eli Zaretskii
2021-10-20 17:13         ` Eli Zaretskii
2021-10-20 17:41           ` Stefan Kangas
2021-10-20 18:19             ` Eli Zaretskii
2021-10-20 21:02         ` Stefan Kangas
2021-10-21  0:45           ` Stefan Kangas
2021-10-21  8:19             ` Eli Zaretskii
2021-10-21 18:36               ` Stefan Kangas
2021-10-21 18:39                 ` Eli Zaretskii
2021-10-21 21:19                   ` Stefan Kangas
2021-10-22  6:16                     ` Eli Zaretskii
2021-10-22  9:03                       ` Stefan Kangas
2021-10-22 12:06                         ` Eli Zaretskii
2021-10-22 12:47                           ` Eli Zaretskii
2021-10-22 14:27                             ` Stefan Kangas

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.