Subject: More Image converter formats

From: Juri Linkov <[email-masked]>
Date: Mon, 28 Jul 2025 09:06:06 +0300

Two improvements for image converter formats:

1. Add AVIF to image file types supported by 'image-convert'.
   The duplicate line for '.webp' is removed since WEBP
   is supported natively now.  But still WEBP is added to
   'imagemagick-enabled-types' for the case when WEBP libs
   are not available.

2. Improve support for XCF by merging all layers.

diff --git a/lisp/files.el b/lisp/files.el
index c05f4fa0e4a..23a8d83ab28 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3248,6 +3248,7 @@ auto-mode-alist
     ;; and after the .scm.[0-9] and CVS' <file>.<rev> patterns too.
     ("\\.[1-9]\\'" . nroff-mode)
     ;; Image file types probably supported by `image-convert'.
+    ("\\.avif\\'" . image-mode)
     ("\\.art\\'" . image-mode)
     ("\\.avs\\'" . image-mode)
     ("\\.bmp\\'" . image-mode)
@@ -3287,7 +3288,6 @@ auto-mode-alist
     ("\\.six\\'" . image-mode)
     ("\\.tga\\'" . image-mode)
     ("\\.wbmp\\'" . image-mode)
-    ("\\.webp\\'" . image-mode)
     ("\\.wmf\\'" . image-mode)
     ("\\.wpg\\'" . image-mode)
     ("\\.xcf\\'" . image-mode)
diff --git a/lisp/image.el b/lisp/image.el
index 40d1364430f..b95dd230914 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -1174,14 +1174,14 @@ imagemagick-types-inhibit
   :version "24.3")
 
 (defcustom imagemagick-enabled-types
-  '(3FR ARW AVS BMP BMP2 BMP3 CAL CALS CMYK CMYKA CR2 CRW
+  '(3FR ARW AVIF AVS BMP BMP2 BMP3 CAL CALS CMYK CMYKA CR2 CRW
     CUR CUT DCM DCR DCX DDS DJVU DNG DPX EXR FAX FITS GBR GIF
     GIF87 GRB HRZ ICB ICO ICON J2C JNG JP2 JPC JPEG JPG JPX K25
     KDC MIFF MNG MRW MSL MSVG MTV NEF ORF OTB PBM PCD PCDS PCL
     PCT PCX PDB PEF PGM PICT PIX PJPEG PNG PNG24 PNG32 PNG8 PNM
     PPM PSD PTIF PWP RAF RAS RBG RGB RGBA RGBO RLA RLE SCR SCT
     SFW SGI SIX SR2 SRF SUN SVG SVGZ TGA TIFF TIFF64 TILE TIM TTF
-    UYVY VDA VICAR VID VIFF VST WBMP WPG X3F XBM XC XCF XPM XV
+    UYVY VDA VICAR VID VIFF VST WBMP WEBP WPG X3F XBM XC XCF XPM XV
     XWD YCbCr YCbCrA YUV)
   "List of ImageMagick types to treat as images.
 Each list element should be a string or symbol, representing one
diff --git a/lisp/image/image-converter.el b/lisp/image/image-converter.el
index 5fe52b98a28..c149addb773 100644
--- a/lisp/image/image-converter.el
+++ b/lisp/image/image-converter.el
@@ -65,7 +65,8 @@ image-converter-file-name-extensions
 (defvar image-converter--converters
   '((graphicsmagick :command ("gm" "convert") :probe ("-list" "format"))
     (ffmpeg :command "ffmpeg" :probe "-decoders")
-    (imagemagick :command "convert" :probe ("-list" "format")))
+    ;; "-layers merge" allows merging all layers in Gimp XCF files.
+    (imagemagick :command ("convert" "-layers" "merge") :probe ("-list" "format")))
   "List of supported image converters to try and required command-line switches.")
 
 (defvar image-converter--extra-converters (make-hash-table :test #'equal))