From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: image-size Date: Thu, 20 Jun 2013 19:01:57 +0300 Message-ID: <837ghopy8a.fsf@gnu.org> References: Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1371744137 27188 80.91.229.3 (20 Jun 2013 16:02:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 20 Jun 2013 16:02:17 +0000 (UTC) Cc: emacs-devel@gnu.org To: Lars Magne Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jun 20 18:02:17 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UphJJ-0000GK-Tj for ged-emacs-devel@m.gmane.org; Thu, 20 Jun 2013 18:02:10 +0200 Original-Received: from localhost ([::1]:43801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UphJJ-00078G-GL for ged-emacs-devel@m.gmane.org; Thu, 20 Jun 2013 12:02:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UphJE-0006zP-2C for emacs-devel@gnu.org; Thu, 20 Jun 2013 12:02:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UphJ9-0000O8-GO for emacs-devel@gnu.org; Thu, 20 Jun 2013 12:02:04 -0400 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:56795) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UphJ9-0000Nx-9W for emacs-devel@gnu.org; Thu, 20 Jun 2013 12:01:59 -0400 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0MOP00E008BP4700@a-mtaout20.012.net.il> for emacs-devel@gnu.org; Thu, 20 Jun 2013 19:01:50 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MOP00EUG8IZ1430@a-mtaout20.012.net.il>; Thu, 20 Jun 2013 19:01:48 +0300 (IDT) In-reply-to: X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.166 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:160753 Archived-At: > From: Lars Magne Ingebrigtsen > Date: Thu, 20 Jun 2013 12:04:52 +0200 > > If I remember correctly from previous discussions, if you call > `image-size', Emacs will go through all the normal stuff it does before > displaying it, including pushing it to the X server, and then ask it how > big it was. I don't think so. Where do you see X calls that "push the image to the X server"? I see no display stuff in image.c, only loading of the image and storing all kinds of metrics of it in an object. Display happens later. > (I'm having a bit of a problem following the logic of lookup_image, > but it looks complicated. :-) The only relevant part is this: img->load_failed_p = ! img->type->load (f, img); This invokes the 'load' method of the relevant image type. > 2) If so, would someone mind very much if I alter `image-size' to do a > "fast path" iff a) we're asking for the pixel size, and b) we have > imagemagick compiled it? If those two things are true, I could add some > code to just ask imagemagick how big the image is without involving the > display engine at all, and things would be a lot faster, I imagine. I see no reason for relying on imagemagick. You will see in each 'load' method a short fragment of code that finds the image size. If you want a "fast path", just add another flag argument to the 'load' method that tells it to return as soon as it computed the size, and that's it. Restricting this to Emacs built with imagemagick would be a regrettable limitation, IMO.