From: Timothy <firstname.lastname@example.org> To: Org-Mode Mailing List <email@example.com> Subject: [PATCH] Prevent displayed images from being re-scaled Date: Wed, 29 Sep 2021 21:33:34 +0800 [thread overview] Message-ID: <firstname.lastname@example.org> (raw) [-- Attachment #1: Type: text/plain, Size: 922 bytes --] Hello, After my last patch providing support for proportional image width attributes (e.g. 70% of the text width), I noticed that the results looked slightly off. Investigating the code lead me to `create-image' which takes the liberty of re-scaling images based on your default font size. As you might imagine, this can be problematic when if you say determine that image should be 70% of the text width, the text width is 1000px, and so the image should be 700px wide — but upon being told to make the image 700 pixels wide `create-image' decides to make it say 850 pixels wide. I personally found that images >~80% wide were being made wider than the buffer, which isn’t good. To make image width behave as expected, we can just specify `:scale 1' when calling `create-image', and that will stop it from re-interpreting the `:width' specification. See the patch attached. All the best, Timothy [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-org-Don-t-change-image-size-based-on-font-size.patch --] [-- Type: text/x-patch, Size: 1113 bytes --] From 9c34dd6aba62d734f6ae9aecaffa76a0250bf495 Mon Sep 17 00:00:00 2001 From: TEC <email@example.com> Date: Wed, 29 Sep 2021 21:29:27 +0800 Subject: [PATCH] org: Don't change image size based on font size * lisp/org.el (org--create-inline-image): When `create-image' is called without the :scale parameter, the image size is expanded based on the default font size (if it is larger than 10px). When displaying images with a specified width in Org buffers, either in pixels or proportional to the text width, this width should not be modified according the to font size. Giving a :scale parameter of 1 prevents this font-size based rescaling. --- lisp/org.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 2ec6566c0..0e7f926f0 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -16518,7 +16518,7 @@ (defun org--create-inline-image (file width) width 'imagemagick) remote? - :width width)))) + :width width :scale 1)))) (defun org-display-inline-images (&optional include-linked refresh beg end) "Display inline images. -- 2.33.0
next reply other threads:[~2021-09-29 13:43 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-29 13:33 Timothy [this message] 2021-10-02 20:30 ` Timothy 2021-10-03 4:57 ` Bastien 2021-10-03 5:45 ` Timothy
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: https://www.orgmode.org/ * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --subject='Re: [PATCH] Prevent displayed images from being re-scaled' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Code repositories for project(s) associated with this inbox: https://git.savannah.gnu.org/cgit/emacs/org-mode.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 NNTP newsgroup(s).