Re: [PATCH] Prevent displayed images from being re-scaled

2021-10-25 Thread Timothy
It’s been quite a few days, so I’ve just pushed this as 9dc08c9.


Re: [PATCH] Prevent displayed images from being re-scaled

2021-10-02 Thread Timothy
Bastien  writes:

> Nitpick: I suggest shortening the ChangeLog part like this:
> *snip*
> The ChangeLog part should not be too verbose, you can add explanations
> after it.

Thanks Bastien, I’ll use that message when I push the commit 👍.

All the best,
Timothy


Re: [PATCH] Prevent displayed images from being re-scaled

2021-10-02 Thread Bastien
Hi Timothy,

Timothy  writes:

> From 9c34dd6aba62d734f6ae9aecaffa76a0250bf495 Mon Sep 17 00:00:00 2001
> From: TEC 
> 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.

Nitpick: I suggest shortening the ChangeLog part like this:

  * lisp/org.el (org--create-inline-image): Set :scale parameter to 1 to
  prevent font-size based rescaling.
  
  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.

The ChangeLog part should not be too verbose, you can add explanations
after it.

Thanks,

-- 
 Bastien



Re: [PATCH] Prevent displayed images from being re-scaled

2021-10-02 Thread Timothy
Hi All,

I intend to push this in the next few days, assuming I don’t get any feedback.

All the best,
Timothy


[PATCH] Prevent displayed images from being re-scaled

2021-09-29 Thread Timothy
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
>From 9c34dd6aba62d734f6ae9aecaffa76a0250bf495 Mon Sep 17 00:00:00 2001
From: TEC 
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