From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#44172: 28.0.50; Exporting image data Date: Fri, 23 Oct 2020 13:18:40 +0200 Message-ID: <87mu0dgpgv.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25064"; mail-complaints-to="usenet@ciao.gmane.io" To: 44172@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 23 13:32:56 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kVvJX-0006P5-JP for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 23 Oct 2020 13:32:55 +0200 Original-Received: from localhost ([::1]:49100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVvJW-0003FL-CD for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 23 Oct 2020 07:32:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51406) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVv66-00056O-QF for bug-gnu-emacs@gnu.org; Fri, 23 Oct 2020 07:19:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43993) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kVv66-000870-FB for bug-gnu-emacs@gnu.org; Fri, 23 Oct 2020 07:19:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kVv66-0000VK-92 for bug-gnu-emacs@gnu.org; Fri, 23 Oct 2020 07:19:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 23 Oct 2020 11:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 44172 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16034519341921 (code B ref -1); Fri, 23 Oct 2020 11:19:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 23 Oct 2020 11:18:54 +0000 Original-Received: from localhost ([127.0.0.1]:55539 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kVv5x-0000Uu-PW for submit@debbugs.gnu.org; Fri, 23 Oct 2020 07:18:54 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:59104) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kVv5u-0000Uk-7J for submit@debbugs.gnu.org; Fri, 23 Oct 2020 07:18:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVv5t-0004lD-WF for bug-gnu-emacs@gnu.org; Fri, 23 Oct 2020 07:18:50 -0400 Original-Received: from quimby.gnus.org ([2a01:4f9:2b:f0f::2]:43678) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVv5q-00085m-Or for bug-gnu-emacs@gnu.org; Fri, 23 Oct 2020 07:18:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:Date:Subject:To:From: Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=hR9BUMSNMB962SYVBYYQQMP4maPj87RtVpRYWxRpKXg=; b=fDptH+IxzQSujDjFeS1FeVE3WF LlRAmOiSqMSEXTBYeLc+uehtRYYAgcIA8jINzJsBaXi1bxbsxFH7XjW3sHk6bx0HMN7IzaFAMxzhu T1HqceC9E+IDx5Q3ryr35i5p/y9/vihDmp6EguYGpUDJFZkoYJHLTkmu/BOxVr891t4E=; Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kVv5l-00009O-O0 for bug-gnu-emacs@gnu.org; Fri, 23 Oct 2020 13:18:44 +0200 X-Now-Playing: Ossia's _Devil's Dance_: "(untitled)" Received-SPF: pass client-ip=2a01:4f9:2b:f0f::2; envelope-from=larsi@gnus.org; helo=quimby.gnus.org X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:191357 Archived-At: 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