Subject: bug#77384: 31.0.50; Image slice is ignored on mode/header/tab line

From: Eli Zaretskii <[email-masked]>
Date: Sun, 30 Mar 2025 17:53:09 +0300

> Date: Sun, 30 Mar 2025 16:01:14 +0200
> From:  David Ponce via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> Following is a short recipe to eval in the *scratch-buffer*, that exhibits
> the issue.  The expected sliced image is inserted in the current buffer,
> but the whole image is displayed in the header line.
> 
> (let* ((img (find-image '((:file "splash.svg"))))
>         (size (image-size img t))
>         (h (frame-char-height))
>         (y (- (cdr size) h h h))
>         (txt (propertize " " 'display (list img `(slice 0 ,y 0.5 ,h)))))
>    (insert txt "\n")
>    (setq header-line-format txt))

You need to do it the other way around:

  (let* ((img (find-image '((:file "splash.svg"))))
	  (size (image-size img t))
	  (h (frame-char-height))
	  (y (- (cdr size) h h h))
	  (txt (propertize " " 'display (list `(slice 0 ,y 0.5 ,h) img))))
     (insert txt "\n")                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     (setq header-line-format txt))

IOW, first slice, then the image spec.