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:
- Image Conversion (0:52 - 19:54): Xah demonstrates using custom Emacs commands to convert images to lossless WebP, noting significant file size reductions (e.g., saving 20MB across a batch of images).
- Batch Processing and Automation (16:33 - 19:48): He shows how to select files in Emacs, move them to temporary directories for bulk processing, and then "unravel" them back to their original locations.
- Link Maintenance (11:25 - 34:35): After converting images, Xah uses a Go script to validate internal links across 13,000 HTML files, addressing broken paths created by the change in file extensions.
- Tools and Philosophy: Xah highlights his reliance on custom, private Emacs packages and command-line tools from Google (cwebp). He discusses his lack of money for his previous open-source releases.
- Discussion Topics:
- Wolfram Language (34:57 - 42:17): Xah shares his perspective on Wolfram Language (Mathematica), emphasizing that it remains far superior to open-source alternatives like Python, SageMath, or Maxima for high-level mathematical computation.
- AI in Coding (42:17 - 50:42): He expresses being impressed by AI's ability to generate tutorials (e.g., for Rust, CSS Grid, and Makefiles), noting that while AI has limitations, it often outperforms the "copy-paste" tutorials found on common web forums.
- Generational Perspectives (50:42 - 56:42): Xah engages in a discussion regarding the impact of AI and modern technology on the capabilities of the younger generation, questioning whether the accessibility of information is leading to a decline in foundational problem-solving skills.
demo emacs commands
xah-dired-to-lossless-webp
and
xah-dired-to-lossy-webp
- git commit xah lee dot info
- convert all png to webp in talk show dir.
- view and compare file size
- fix all links in html
- do a site link check
- Golang: Validate Website Local Links 📜
(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))