From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Third Newsgroups: gmane.emacs.devel Subject: Re: Image transformations Date: Sun, 30 Jun 2019 15:38:46 +0100 Message-ID: <20190630143846.GA8886@breton.holly.idiocy.org> References: <83d0jdv68i.fsf@gnu.org> <20190617211332.GA55597@breton.holly.idiocy.org> <83a7e6na26.fsf@gnu.org> <20190625183352.GA18019@breton.holly.idiocy.org> <838stplcgb.fsf@gnu.org> <83v9wri0yd.fsf@gnu.org> <20190628183604.GA51376@breton.holly.idiocy.org> <83imsph4kj.fsf@gnu.org> <20190629194959.GA71373@breton.holly.idiocy.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="H+4ONPRPur6+Ovig" Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="10765"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.12.0 (2019-05-25) Cc: Eli Zaretskii , emacs-devel@gnu.org To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jun 30 16:39:20 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hhaz9-0002a1-PN for ged-emacs-devel@m.gmane.org; Sun, 30 Jun 2019 16:39:20 +0200 Original-Received: from localhost ([::1]:44966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hhaz2-0006tK-4a for ged-emacs-devel@m.gmane.org; Sun, 30 Jun 2019 10:39:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56613) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hhayv-0006pk-Sh for emacs-devel@gnu.org; Sun, 30 Jun 2019 10:39:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hhayu-0004dk-NI for emacs-devel@gnu.org; Sun, 30 Jun 2019 10:39:05 -0400 Original-Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:42886) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hhayh-00046R-1E; Sun, 30 Jun 2019 10:38:52 -0400 Original-Received: by mail-wr1-x42a.google.com with SMTP id x17so10973712wrl.9; Sun, 30 Jun 2019 07:38:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=AWg7th+0dSu/3hg5IakxWAyYtc7f+3IhAlmWlFjXgfc=; b=PHx2k1qiSR6uF57qQSSPuwtkk0RgA3VTRVQt9YdFrbzTBrzMBrPmj3bv/1mYYr+pR+ ytsV0mvfF+bY2YUCqYG1LfbU1qYFQPKbOBNS2T9NEmr45xPHEgNBj2ejLY5V2vhSwVd1 //9VDdpppljBnqEOnFNGDW8QmCtsobmaWI1nO5fgbiejPoXAK9Y74SutOyLiq79CuTZL WVYMojpfgpmSDft7QMY5XfiW38ywI/NVm+dtJIGWj6G03oAzoT2NtbGox44KXib+3Nq2 3l8LAImfdez4k0nENBSSB63Env2OGnXv3FNkMvMIS1O65PT7ITtPCGxFQrlAT905bf8q Byhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=AWg7th+0dSu/3hg5IakxWAyYtc7f+3IhAlmWlFjXgfc=; b=rExeOgQJX6CmwjuNYbb60GfMd1stVSY2g0y1iPn475iY4VZ6u/VtlvBPNaZ9Pa7YF7 wBMnQKtOOtwSl7DKKHGRHqlTTKdzyQQ8optPmtK9L7fngtzhSg1Pan74/jWU9gR0iA33 uzR7lEmB+LREQNkoRqJ75vn98jrG5MKfvJh/3LWg48DSRNck9DzyD6s9rZVOiqQCoGA5 d43tbg0Qfa5fHq1LSmDspTbydnjdbhUcgE9AamkTY2ib6Hd4aNX2J7HY1KjCMDopQBAV PqooR5jP03bN2fo3f1IfUcL9LlOVM+O2d1oZ/ZN9gVzRB5vDyquR9XIvd9wRMJ4ST7SR 5l+w== X-Gm-Message-State: APjAAAUN00DIzSEh7pJlkEt7FLmdIoUSIfHtJHOmoMWVeIFFgt4Q6fXP wKcW/dTT9ZOmpXTf3wBBz1+1XmwQ X-Google-Smtp-Source: APXvYqwMJawy08bh5T4HZuLkYAtf8cdy8qblZ+x21Hazo18ony1gWQN8kGb0n4j9OpNkv7eawLodjA== X-Received: by 2002:a5d:53d2:: with SMTP id a18mr16112616wrw.98.1561905529270; Sun, 30 Jun 2019 07:38:49 -0700 (PDT) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-4c3a-3ac6-07f3-e813.holly.idiocy.org. [2001:8b0:3f8:8129:4c3a:3ac6:7f3:e813]) by smtp.gmail.com with ESMTPSA id e7sm6076230wmd.0.2019.06.30.07.38.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Jun 2019 07:38:48 -0700 (PDT) Content-Disposition: inline In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42a X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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" Xref: news.gmane.org gmane.emacs.devel:238255 Archived-At: --H+4ONPRPur6+Ovig Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Sat, Jun 29, 2019 at 09:53:53PM +0200, Lars Ingebrigtsen wrote: > Alan Third writes: > > > If you want to change to defaulting to ImageMagick where available I’m > > sure we can. > > I've resorted to using a function like this in every package that > inserts an image: > > (defun foo--image-type () > (if (or (and (fboundp 'image-transforms-p) > (image-transforms-p)) > (not (fboundp 'imagemagick-types))) > nil > 'imagemagick)) > > Which is pretty annoying. Something like the attached might help. Although if someone included ImageMagick to support some obscure image type it might result in slower image loads than native scaling for png and jpeg, and so on. I don’t know if we care much about that. Personally I’ve not noticed any great speed increase, but anecdotally I’ve heard that native transforms are far faster. If it does turn out to be an issue then it should be quite easy to just use ImageMagick to load the image, then use native transforms when available. -- Alan Third --H+4ONPRPur6+Ovig Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Default-to-ImageMagick-when-transforms-are-requested.patch" >From dfc19db48f85538b0d60cd0b1e0787811f8daca2 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sun, 30 Jun 2019 15:24:46 +0100 Subject: [PATCH] Default to ImageMagick when transforms are requested * lisp/image.el (create-image): Default to ImageMagick when transforms are requested. --- lisp/image.el | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lisp/image.el b/lisp/image.el index b58b1dc954..70c988857c 100644 --- a/lisp/image.el +++ b/lisp/image.el @@ -436,13 +436,24 @@ create-image Image file names that are not absolute are searched for in the \"images\" sub-directory of `data-directory' and `x-bitmap-file-path' (in that order)." + (when (not (plist-get props :scale)) + (let ((scale (image-compute-scaling-factor image-scaling-factor))) + (when (/= 1 scale) (setq props (append (list :scale scale) props))))) + ;; Default to ImageMagick if a transform is requested. + (if (and (not type) + (fboundp 'imagemagick-types) + (or (plist-get props :scale) + (plist-get props :width) + (plist-get props :height) + (plist-get props :max-width) + (plist-get props :max-height) + (plist-get props :rotation) + (plist-get props :crop))) + (setq type 'imagemagick)) ;; It is x_find_image_file in image.c that sets the search path. (setq type (image-type file-or-data type data-p)) (when (image-type-available-p type) (append (list 'image :type type (if data-p :data :file) file-or-data) - (and (not (plist-get props :scale)) - (list :scale - (image-compute-scaling-factor image-scaling-factor))) props))) (defun image--set-property (image property value) -- 2.21.0 --H+4ONPRPur6+Ovig--