Subject: bug#44172: 28.0.50; Exporting image data

From: Alan Third <[email-masked]>
Date: Fri, 23 Oct 2020 17:24:19 +0100

On Fri, Oct 23, 2020 at 01:18:40PM +0200, Lars Ingebrigtsen wrote:
> 
> 1) Making image data available to Emacs Lisp.
> 
> This is something that I've often wanted for other reasons -- I want to
> know how an SVG was rendered, for instance (especially when doing
> font-based stuff), and there's no way to actually tell.
> 
> So I think Emacs should have a function like
> 
> (export-image-data IMAGE &rest SPECS)
> 
> that will just take the image cache data for IMAGE (or the frame
> specified by SPECS, if multi-frame) and dump the RGB(A) data into the
> current buffer (which should be unibyte, for efficiency), and return
> a plist of width/height/bytes-per-pixel/rgb(a) ordering.  This is
> basically the PPM binary format, but without the heading.
> 
> This allows us to do easy transforms like cropping and rotating from
> Lisp, too.

Are you talking about using an image spec that we use to display
images, which can already include rotation and resizing?

That would be difficult because the stored image data doesn't have
those transformations applied, unless you're using imagemagick. We'd
have to draw it to a buffer (either on-screen or off) and then read
back that data.

-- 
Alan Third