Xah Talk Show 2026-06-25 Ep797. write emacs lisp command to convert png to webp, of image tag in 10 thousand html files

Video Summary (Generated by AI, Edited by Human.)

In this episode (Ep797), Xah Lee demonstrates how to optimize a website by converting thousands of PNG images to the WebP format. He walks through his personal Emacs Lisp workflow for image processing and file management.

Key Highlights of the Process:

demo emacs commands xah-dired-to-lossless-webp and xah-dired-to-lossy-webp

(defun xah-dired-to-lossless-webp (zfiles)
  "Create a webp version of images of marked files in `dired'.
Call external command cwebp.

Created: 2026-06-18
Version: 2026-06-21"
  (interactive
   (let ((xflist
          (cond
           ((eq major-mode 'dired-mode) (dired-get-marked-files))
           ((eq major-mode 'image-mode) (list buffer-file-name))
           (t (list (read-from-minibuffer "file name:"))))))
     (list xflist)))
  (let ((xoutbuf (get-buffer-create "*xah-dired output*" t)))
    (message "doing xah-dired-to-lossless-webp. wait")
    (mapc
     (lambda (x)
       (let ((xnewname (concat (file-name-sans-extension x) "_ll" ".webp")))
         (call-process "cwebp" nil xoutbuf nil "-lossless" x "-o" xnewname)))
     zfiles))
  (dired-revert))