Subject: bug#53952: 27.1; insert-image sometimes unexpectedly truncates images

From: Eli Zaretskii <[email-masked]>
Date: Sat, 12 Feb 2022 14:31:19 +0200

> From: Markus Triska <[email-masked]>
> Date: Sat, 12 Feb 2022 11:12:37 +0100
> 
>     (defun insert-bar (width)
>       (let* ((height 5)
>              (data (with-temp-buffer
>                      (insert (format "P1\n%s %s\n" width height))
>                      (dotimes (_ height)
>                        (insert (make-string width ?1) "\n"))
>                      (buffer-string))))
>         (insert-image `(image :type pbm :data ,data)) "t"))
> 
>     (progn
>       (insert "\n")
>       (dotimes (_ 3)
>         (insert-bar (/ (window-pixel-width) 3))
>         (insert "         ")))
> 
> Then evaluate the forms with M-x eval-buffer RET.
> 
> The code is meant to insert 3 bars of equal length, each 1/3 of the
> window size in pixels.
> 
> Unexpectedly, the rightmost bar is much shorter than the other two bars.

Emacs doesn't support wrapping of images, it never did.  The display
engine chops images at the right edge of the window.

> I say "unexpectedly", because the documentation of insert-image (which
> is used to insert the image by the forms above) states:
> 
>     "If SLICE is ‘nil’ or omitted the whole image is inserted."

I added a note there about the forced truncation of images.

> If possible, I would like to insert the entire image no matter where it
> appears in the buffer, even if scrolling is necessary to reveal
> remaining parts. Is there a way to do this?

No, not with how we display images at this time.