![]() |
#1 |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 488
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
Variable/fixed image height
In the Kindle OS, images with a fixed height (and no specified width) that would exceed the screen width are resized proportionally to fit the screen width. In other words the fixed height is functionally overwritten to fit the image proportionally to the screen if honoring it (proportionally) would result in the image's exceeding the screen width. Otherwise, the fixed height value is honored as long as the implied image width is less than the width of the screen.
How would someone code this kind of conditional behavior in css for epub2 to acheive similar outcomes on non-Kindle, epub-based readers? Last edited by ElMiko; 09-27-2025 at 08:22 AM. |
![]() |
![]() |
![]() |
#2 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,377
Karma: 20212733
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Try an svg wrapper.
|
![]() |
![]() |
![]() |
#3 |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 488
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
Okay, so lets say i want the attached image to have a height of 4em (unless this would results in a concomitant width that exceeded the device's screen width)...
how would this work with an svg wrapper, bearing in mind this is not a standalone image, but one that occurs with normal text above and below it? |
![]() |
![]() |
![]() |
#4 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,566
Karma: 20150435
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
What's wrong with "max-height: 4em; max-width: 100%"? Is the natural height of the image less than 4em?
|
![]() |
![]() |
![]() |
#5 |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 488
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
As I understand it, "em" isn't a absolute unit, it's a relative unit. So, I mean, I guess it's as natural as any other em value.
Regarding max-width, the issue is that setting it at 100% means that the image will appear to stretch vertically if the screen width is too narrow relative to the defined height. See the attached images: test1 has a viewing window that accomodates both the defined 4em height and the proportionally scaled width; test2 shows what happens when the viewing window is narrower than a 4em height and a proportional width would allow—namely, it preserves the height and squishes it width-wise to fit it all on the screen. Last edited by ElMiko; Yesterday at 01:49 PM. |
![]() |
![]() |
![]() |
#6 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 80,356
Karma: 148951763
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
![]() |
![]() |
![]() |
#7 | ||
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,566
Karma: 20150435
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Quote:
Quote:
Last edited by Jellby; Yesterday at 02:38 PM. |
||
![]() |
![]() |
![]() |
#8 | |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 488
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
Quote:
But even if it were the exact case, this is the kind of advice that is really crazy-making: -- Question: How do i solve problem X? -- Answer: By deciding you no longer want to solve problem X. The issue I described in my original post was not "I want to make a image of text behave a certain way" it was "I want to make an image behave a certain way", so telling me not to use text images is a non-sequitur. @Jellby - I think I'm seeing the difference between our two codes, and I don't really understand what the implications are: Basically, in your test version the height is defined at the <div> level, not the <img> level, resulting in the correct scaling that you observed. I'm confused, though, why definiing the height at the <img> level would result in squishing, and I'm wondering if there are any other unintended consequences depending on which level the height/width values are assigned. Do you know? EDIT: Welp, I've found unintended consequences... Whatever protocol PageEdit is using to parse height/width values defined at the <div> results in the image going off the screen (see test3, attached). And in the EpubJSReader Sigil plugin it cuts off part of the right-hand side of the image (see test4). Last edited by ElMiko; Yesterday at 04:02 PM. |
|
![]() |
![]() |
![]() |
#9 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 80,356
Karma: 148951763
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
![]() |
![]() |
![]() |
#10 |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 488
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
It's not a valid solution to the original problem as it was articulated. Has nothing to do with what I might like or not. It has to do with your addressing the topic. You might as well have objected to my creating an ebook out of a fraction of the "Lorem ipsum..." text. Its content was as relevant to the question as the visual content of the image.
Instead, you have taken the liberty of inventing your own problem to solve, namely: someone desperately wants to know if JSWolf thinks an image file is the worst way to display text in an ebook, and is annoyed by it. So, I guess on that count you absolutely nailed the answer. Last edited by ElMiko; Yesterday at 05:54 PM. |
![]() |
![]() |
![]() |
#11 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 80,356
Karma: 148951763
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
To solve the problem, make the image the height you want. Then the only issue will be if it has to reduced in width. You have two options. It can be reduced so the aspect ratio is correct or reduced so the aspect ratio is not correct.
|
![]() |
![]() |
![]() |
#12 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,861
Karma: 8821117
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Well, you want a solution for epub2. With this restriction in mind, you'll need to use an SVG wrapper and assign it the "display: inline-block; width: 100%; margin: 1em 0; text-indent:0" properties. This seems to work:
Inlined_Block_SVG.epub Crop to content the image before including it in the svg wrapper and use margins (or paddings) to add blank spaces. Of course, I set "margin; 1em 0" but you can set the values you want. Last edited by RbnJrg; Yesterday at 07:15 PM. |
![]() |
![]() |
![]() |
#13 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 80,356
Karma: 148951763
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
![]() |
![]() |
![]() |
Tags |
image height, image scaling |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
line-height is fixed? | nano5 | Viewer | 5 | 01-25-2025 08:01 AM |
Image height | JSWolf | KOReader | 6 | 03-29-2021 04:29 PM |
QT5 and image height | Turtle91 | Sigil | 23 | 02-21-2013 01:44 PM |
Image height in div | soparch | ePub | 5 | 03-29-2012 01:18 PM |
What image height causes images to fill the screen? | karenbryant | ePub | 7 | 01-04-2012 04:23 AM |