From: Lars Ingebrigtsen <larsi@gnus.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 25583@debbugs.gnu.org
Subject: bug#25583: 26.0.50; :width/:max-width and vice versa in images
Date: Tue, 31 Jan 2017 17:02:16 +0100 [thread overview]
Message-ID: <m3k29bnrp3.fsf@stories> (raw)
In-Reply-To: <83efzjw7cz.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 31 Jan 2017 17:56:44 +0200")
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Lars Ingebrigtsen <larsi@gnus.org>
>> Date: Mon, 30 Jan 2017 22:42:44 +0100
>>
>> As far as I can tell, it isn't documented what should happen if you have
>> both :width and :max-height set in image specification, or vice versa.
>
> I see this in the ELisp manual:
>
> ‘:width WIDTH, :height HEIGHT’
> The ‘:width’ and ‘:height’ keywords are used for scaling the image.
> If only one of them is specified, the other one will be calculated
> so as to preserve the aspect ratio. If both are specified, aspect
> ratio may not be preserved.
>
> ‘:max-width MAX-WIDTH, :max-height MAX-HEIGHT’
> The ‘:max-width’ and ‘:max-height’ keywords are used for scaling if
> the size of the image of the image exceeds these values. If
> ‘:width’ is set it will have precedence over ‘max-width’, and if
> ‘:height’ is set it will have precedence over ‘max-height’, but you
> can otherwise mix these keywords as you wish. ‘:max-width’ and
> ‘:max-height’ will always preserve the aspect ratio.
>
> So I think the behavior that should be expected is well documented.
No, the case where :width and :max-height are both specified is not
documented. Only :width and :max-width (and :height and :max-height).
>> Here's the use case: I want to display images that are mostly square,
>> but can sometimes be rectangular, and I want them to be displayed in max
>> width if possible, even if they are smaller than that width originally,
>> but not exceeding a certain height.
>>
>> So I thought ":width 400 :max-height 500" should do the trick, but
>> apparently compute_image_size just ignores :max-height in this case.
>>
>> I think :max-height should "win" here... (That is, the width will end up
>> smaller than 400 if making it 400 wide will make height exceed 500.)
>
> Sorry, I don't understand how :max-height could (or should) affect the
> width.
The aspect ratio is preserved in all these transforms, so changing (or
restricting) the width changes the height and vice versa.
> And where do you see in the code that :max-height is ignored
> if :width is given? My reading of the code is that that :max-height
> is ignored only if :height is given.
You end up here:
if (desired_height == -1)
{
value = image_spec_value (spec, QCmax_height, NULL);
if (NATNUMP (value))
{
int max_height = min (XFASTINT (value), INT_MAX);
if (max_height < height)
desired_height = max_height;
}
}
height is not larger than max_height here, so desired_height is not set.
if (desired_width != -1 && desired_height == -1)
/* w known, calculate h. */
desired_height = scale_image_size (desired_width, width, height);
And then this is done, and :max-height is ignored.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
next prev parent reply other threads:[~2017-01-31 16:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-30 21:42 bug#25583: 26.0.50; :width/:max-width and vice versa in images Lars Ingebrigtsen
2017-01-31 15:56 ` Eli Zaretskii
2017-01-31 16:02 ` Lars Ingebrigtsen [this message]
2017-07-15 0:48 ` Lars Ingebrigtsen
2017-07-15 1:24 ` Semi-not-very interactive tests Lars Ingebrigtsen
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3k29bnrp3.fsf@stories \
--to=larsi@gnus.org \
--cc=25583@debbugs.gnu.org \
--cc=eliz@gnu.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.