From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Visuwesh Newsgroups: gmane.emacs.bugs Subject: bug#58041: [PATCH] docview: Use svg images when using mupdf for conversion Date: Thu, 12 Jan 2023 22:17:50 +0530 Message-ID: <87zganwvgp.fsf@gmail.com> References: <87k05t848c.fsf@gmail.com> <87eds5zhf7.fsf@gmail.com> <87v8lfy8g5.fsf@gmail.com> <87fscgxng0.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22107"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 58041@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 12 17:50:43 2023 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 1pG0mp-0005RK-38 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 12 Jan 2023 17:50:43 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pG0lF-0007Ob-NC; Thu, 12 Jan 2023 11:49:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pG0lD-0007Np-DU for bug-gnu-emacs@gnu.org; Thu, 12 Jan 2023 11:49:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pG0lD-0001WX-2p for bug-gnu-emacs@gnu.org; Thu, 12 Jan 2023 11:49:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pG0lC-0001OV-GS for bug-gnu-emacs@gnu.org; Thu, 12 Jan 2023 11:49:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Visuwesh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 12 Jan 2023 16:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58041 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 58041-submit@debbugs.gnu.org id=B58041.16735420825175 (code B ref 58041); Thu, 12 Jan 2023 16:49:02 +0000 Original-Received: (at 58041) by debbugs.gnu.org; 12 Jan 2023 16:48:02 +0000 Original-Received: from localhost ([127.0.0.1]:48479 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pG0kD-0001LE-Hr for submit@debbugs.gnu.org; Thu, 12 Jan 2023 11:48:02 -0500 Original-Received: from mail-pj1-f66.google.com ([209.85.216.66]:46856) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pG0kB-0001KO-S9 for 58041@debbugs.gnu.org; Thu, 12 Jan 2023 11:48:00 -0500 Original-Received: by mail-pj1-f66.google.com with SMTP id z4-20020a17090a170400b00226d331390cso21553352pjd.5 for <58041@debbugs.gnu.org>; Thu, 12 Jan 2023 08:47:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=2oqo8lGB2SpsktdHgMJJogp6OOwm6PZscTArQfoJ4Xc=; b=nr68Zrrnoa//X/NsQ5hMOuYglLYjms1R3XGUHugth1qR0LkrEU/4p7WEbEALs6pMD4 417nKicJ4cYeIUsJ8kk43F+20ch2EP78EYGviy88/aZW3dsNZ/BuL9sGO+rhPg7E2wdg dUVUJfRMSI4lWF6iu8oOuxRcTuDNi5xtIQcr05CBfHPDBz0pEld/vKy0FAm14RasIV4W 9s7LrBoJWv6yHi5E0p43AHlGP3NidOecz2b67YOQJggnuHcFWHz5hW+m4uCOfCcO/0+F sS8tnr07YpcsEJR4aLaUIYxxefgeDi5Ft5Ka2KDUEPG9RcXUBaHuXPUBcrwbcQz8OyVo AbOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2oqo8lGB2SpsktdHgMJJogp6OOwm6PZscTArQfoJ4Xc=; b=dBBBXIgLrCJuPkSBpcLs33Zadiv8Kp3P12rBlOOwEOjJjbWNymZm8+91TuVmeFK9MP BMKnXWmsWLgjf1R+HknjVTgUBlVMigZm2ssoFOm4q7K1nj0n/VPgRhQZWSBwh9AUXL+p KdkkdC0ZT0GmGdk6jrev9DfrIJcq/QHt4wQgYXFSE2ZRK8SatV5dTTLr+zQ3+CCay4JL FQtn2L6iyryafx4gT0HEYeE51qFWBj1oYPULPscizW8cPs07fMJhe9yOsN8HOGoandS9 D9YSLRiiZLxlSERRbmIlmGzlntR9wMo9QgZ/Qd71fbq9Tbd6AxG5V80Pdt9b1V8li5CE 2WFg== X-Gm-Message-State: AFqh2kp3mEpPU7weQ4fQ6yrd/U8cFTXaSNdJMQmTPxHk4ZH9IiT68H8d 3AKjGjkLxO4N3yLr5rO5Qug= X-Google-Smtp-Source: AMrXdXvYvipmsN8vDSn67WhlgLZEosqXwvZwHDi6xFs/wV4okYLgzQKE50KHXJt9tr399JH3kUnENw== X-Received: by 2002:a17:902:f544:b0:194:65c8:da70 with SMTP id h4-20020a170902f54400b0019465c8da70mr1971774plf.45.1673542073721; Thu, 12 Jan 2023 08:47:53 -0800 (PST) Original-Received: from localhost ([115.240.90.130]) by smtp.gmail.com with ESMTPSA id i16-20020a170902c95000b00189847cd4acsm12432098pla.237.2023.01.12.08.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 08:47:53 -0800 (PST) In-Reply-To: (Stefan Monnier via's message of "Thu, 12 Jan 2023 11:33:49 -0500") 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:253239 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable [=E0=AE=B5=E0=AE=BF=E0=AE=AF=E0=AE=BE=E0=AE=B4=E0=AE=A9=E0=AF=8D =E0=AE=9C= =E0=AE=A9=E0=AE=B5=E0=AE=B0=E0=AE=BF 12, 2023] Stefan Monnier via "Bug repo= rts for GNU Emacs, the Swiss army knife of text editors" wrote: >> --- a/lisp/doc-view.el >> +++ b/lisp/doc-view.el >> @@ -921,7 +921,7 @@ doc-view-shrink-factor >> (defun doc-view-enlarge (factor) >> "Enlarge the document by FACTOR." >> (interactive (list doc-view-shrink-factor)) >> - (if doc-view-scale-internally >> + (if (or doc-view-scale-internally doc-view-mupdf-use-svg) >> (let ((new (ceiling (* factor doc-view-image-width)))) >> (unless (equal new doc-view-image-width) >> (setq-local doc-view-image-width new) >> @@ -941,7 +941,7 @@ doc-view-shrink >> (defun doc-view-scale-reset () >> "Reset the document size/zoom level to the initial one." >> (interactive) >> - (if doc-view-scale-internally >> + (if (or doc-view-scale-internally doc-view-mupdf-use-svg) >> (progn >> (kill-local-variable 'doc-view-image-width) >> (doc-view-insert-image > > Hmm.... `doc-view-mupdf-use-svg` means "use SVG when the backend > is mupdf" but we don't know here whether the backend is mupdf, so this > will misfire when using something else than mupdf, no? Ah yes, of course. Somehow, I managed to completely forget about the other file formats supported by doc-view like djvu (since I only use file formats that use mupdf in the end). How about the below revised patch? --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Use-internal-image-scaling-when-using-SVG-images-in-.patch >From 70864205f1595815470639cd2ad47c5465206f03 Mon Sep 17 00:00:00 2001 From: Visuwesh Date: Thu, 12 Jan 2023 12:03:49 +0530 Subject: [PATCH] Use internal image scaling when using SVG images in doc-view * lisp/doc-view.el (doc-view-enlarge, doc-view-scale-reset): Default to changing the :width image property when using SVG images even if doc-view-scaling-internally is nil. (doc-view--image-type): Document the new possible image type. (bug#58041) --- lisp/doc-view.el | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lisp/doc-view.el b/lisp/doc-view.el index 7c272f52fb..cdca17f5af 100644 --- a/lisp/doc-view.el +++ b/lisp/doc-view.el @@ -489,7 +489,7 @@ doc-view-single-page-converter-function (defvar-local doc-view--image-type nil "The type of image in the current buffer. -Can be `png' or `tiff'.") +Can be `png', `svg', or `tiff'.") (defvar-local doc-view--image-file-pattern nil "The `format' pattern of image file names. @@ -921,7 +921,9 @@ doc-view-shrink-factor (defun doc-view-enlarge (factor) "Enlarge the document by FACTOR." (interactive (list doc-view-shrink-factor)) - (if doc-view-scale-internally + (if (or doc-view-scale-internally + (and (eq doc-view--image-type 'svg) + doc-view-mupdf-use-svg)) (let ((new (ceiling (* factor doc-view-image-width)))) (unless (equal new doc-view-image-width) (setq-local doc-view-image-width new) @@ -941,7 +943,9 @@ doc-view-shrink (defun doc-view-scale-reset () "Reset the document size/zoom level to the initial one." (interactive) - (if doc-view-scale-internally + (if (or doc-view-scale-internally + (and (eq doc-view--image-type 'svg) + doc-view-mupdf-use-svg)) (progn (kill-local-variable 'doc-view-image-width) (doc-view-insert-image -- 2.38.1 --=-=-= Content-Type: text/plain This does the expected on my end with doc-view-scale-internally to nil: when visiting a djvu file and zooming in, it regenerates the images; when visiting a docx file and zooming in, it modifies the :width image property (i.e., no regeneration). >>> I wasn't thinking of duplicating the code, but of rethinking the naming >>> a bit. I think what we meant by "pdf->png" is actually the process that >>> extracts pages (which just happened to use the PNG format and now can >>> also use the SVG format). > >> Indeed, it is a misleading name. This change will have to go to master, >> I believe? I have to look around a bit more to see where the function >> is being used. >> There's also the fact that there's more than one more program that can >> generate SVG files (as Gregory pointed out in this thread) so it might >> be nice to have pdf->png and pdf->svg "function variables" and a "super >> function" that actually does the job. Hopefully, this will allow to >> fall back gracefully to PNG if SVG generation is faulty. > > Indeed, I think there's some cleanup/orthogonalization in order here. When I have more time and familiarity, I will try to give this a shot. > Stefan --=-=-=--