unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#44172: 28.0.50; Exporting image data
@ 2020-10-23 11:18 Lars Ingebrigtsen
  2020-10-23 11:45 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-23 11:18 UTC (permalink / raw)
  To: 44172


There's been some discussion off-list about adding simple image
manipulation functions to Emacs, and there's really only three
transforms that are in scope for Emacs: Cropping, rotating and resizing.

Now, there are packages out there that allow doing this, but they rely
on external programs to actually do the image wrangling.  I wondered
what it would take to make it possible to do this in-Emacs, and I think
we basically have all the needed stuff -- we just need to hook it up and
make it available.

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.

2) Create image files.

But mogrifying images is all well and good, but if we can't save the
data, it's not much use.  Of course we could just save the data as PPM,
but that's not very helpful.  So Emacs needs to be able to write image
files...  which sounds like a big thing, but it isn't really: As long as
we can save .jpeg and .png files, that's fine.

Fortunately, Emacs links with libpng and libjpeg already, so adding a

(encode-image-data TYPE)

function is less work than it would seem.




In GNU Emacs 28.0.50 (build 124, x86_64-pc-linux-gnu, GTK+ Version 3.24.23, cairo version 1.16.0)
 of 2020-10-22 built on xo
Repository revision: 954a4decfcc8e41084789516773b22d0adc11d91
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12008000
System Description: Debian GNU/Linux bullseye/sid


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no






^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-11-06 18:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-23 11:18 bug#44172: 28.0.50; Exporting image data Lars Ingebrigtsen
2020-10-23 11:45 ` Eli Zaretskii
2020-10-23 11:49   ` Lars Ingebrigtsen
2020-10-23 16:24 ` Alan Third
2020-10-24 19:51   ` Lars Ingebrigtsen
2021-10-31 15:04 ` Stefan Kangas
2021-10-31 15:11   ` Lars Ingebrigtsen
2021-10-31 15:39     ` Stefan Kangas
2021-10-31 15:42       ` Lars Ingebrigtsen
2021-11-05 13:57         ` bug#44172: bug#49347: image-save not working as expected for transformed image saving! Stefan Kangas
2021-11-06  0:38           ` Lars Ingebrigtsen
2021-11-06  8:00             ` Stefan Kangas
2021-11-06 18:12               ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).