Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 03-18-2026, 09:07 PM   #61
ElMiko
Fanatic
ElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileRead
 
ElMiko's Avatar
 
Posts: 546
Karma: 65460
Join Date: Jun 2011
Device: Kindle Voyage, Boox Go 7
Quote:
Originally Posted by RbnJrg View Post
The Readium Sigil plugin displays nice in my system the epub you posted here. But maybe your issue is because the height of your Readium's window is lower than 32em (the height you are using for the image).
Nope, that's not it. Tested at 10em and 20em. As you can see the text shifts up and down the page according the em units assigned to the image, but the image remains full screen....

I wonder if this is a bug.
Attached Thumbnails
Click image for larger version

Name:	ImageScale10.jpg
Views:	8
Size:	329.4 KB
ID:	221888   Click image for larger version

Name:	ImageScale20.jpg
Views:	8
Size:	337.9 KB
ID:	221889  
ElMiko is online now   Reply With Quote
Old Yesterday, 09:16 AM   #62
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,925
Karma: 9553607
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by ElMiko View Post
Nope, that's not it. Tested at 10em and 20em. As you can see the text shifts up and down the page according the em units assigned to the image, but the image remains full screen....

I wonder if this is a bug.
I was able to reproduce your issue in Readium plugin.

Click image for larger version

Name:	Readium.png
Views:	4
Size:	72.6 KB
ID:	221895

It's not a bug, it's your code; the issue is originated by the font size employed in Readium. When the size is lower than 80% the text overlaps the image. In fact, the text overlaps the image even with a size of 100%, but because the white space that surrounds the image you can't see that. As I said, don't use "em" to set the height of the image.
RbnJrg is offline   Reply With Quote
Old Yesterday, 04:15 PM   #63
QuietShelfLife
Enthusiast
QuietShelfLife began at the beginning.
 
Posts: 36
Karma: 10
Join Date: Feb 2026
Device: iPad
RbnJrg nailed it — em units for image height are a trap because they're tied to font size, which is the one thing every EPUB reader actively lets users override. Your 20em image renders at one size with the default font, then completely different when someone bumps it up or down.

In practice, the most reliable approach I've found for constraining image height is max-height with viewport units:

Code:
max-height: 90vh; width: auto; height: auto;
Most modern readers (Apple Books, Readium-based apps, Thorium, Kobo) handle vh correctly now. The image scales relative to the screen rather than the font, which is what you actually want.

For older readers that don't support viewport units, max-height: 100% on the image with the parent container set to a percentage of the page height is the safest fallback. Not as precise, but at least it won't overlap text.

The fundamental issue is that EPUB wants everything reflowable and relative, but images are fixed-ratio content. Anything font-relative (em, rem, ex) will always be unpredictable for images.
QuietShelfLife is offline   Reply With Quote
Old Yesterday, 04:35 PM   #64
ElMiko
Fanatic
ElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileRead
 
ElMiko's Avatar
 
Posts: 546
Karma: 65460
Join Date: Jun 2011
Device: Kindle Voyage, Boox Go 7
Quote:
Originally Posted by QuietShelfLife View Post
RbnJrg nailed it — em units for image height are a trap because they're tied to font size, which is the one thing every EPUB reader actively lets users override. Your 20em image renders at one size with the default font, then completely different when someone bumps it up or down.

In practice, the most reliable approach I've found for constraining image height is max-height with viewport units:

Code:
max-height: 90vh; width: auto; height: auto;
Most modern readers (Apple Books, Readium-based apps, Thorium, Kobo) handle vh correctly now. The image scales relative to the screen rather than the font, which is what you actually want.

For older readers that don't support viewport units, max-height: 100% on the image with the parent container set to a percentage of the page height is the safest fallback. Not as precise, but at least it won't overlap text.

The fundamental issue is that EPUB wants everything reflowable and relative, but images are fixed-ratio content. Anything font-relative (em, rem, ex) will always be unpredictable for images.
I'm sorry. But I'm still confused... At 10em shouldn't the image be ten times the height of the font (at whatever size)?

If so, why is it always full screen in my example?

@RbnJrg - you say you got the code to replicate the effect, but what did you change from your previous attempt with the same code that appeared to be producing a normal image?

Last edited by ElMiko; Yesterday at 05:20 PM.
ElMiko is online now   Reply With Quote
Old Yesterday, 06:06 PM   #65
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,925
Karma: 9553607
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by ElMiko View Post
I'm sorry. But I'm still confused... At 10em shouldn't the image be ten times the height of the font (at whatever size)?
You are defining the height in two places: in the parent element and in the image tag, so Readium is taking the height of the parent element. You need to add !important to the size of the image to give it priority:

Code:
.autoIMG {
	text-indent: 0;
	text-align: center;
	max-height: 32em;
	margin: 0;
	}
.autoIMGimage {
	width: auto;
        max-height: 32em !important;
	margin: 0 auto;
	display: block;
	}
Of that way, the height of the image will be ten times the height of the font.

Quote:
@RbnJrg - you say you got the code to replicate the effect, but what did you change from your previous attempt with the same code that appeared to be producing a normal image?
The issue is with your original code; I didn't change anything to reproduce the problem.
RbnJrg is offline   Reply With Quote
Old Yesterday, 07:02 PM   #66
ElMiko
Fanatic
ElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileRead
 
ElMiko's Avatar
 
Posts: 546
Karma: 65460
Join Date: Jun 2011
Device: Kindle Voyage, Boox Go 7
Quote:
Originally Posted by RbnJrg View Post
You are defining the height in two places: in the parent element and in the image tag, so Readium is taking the height of the parent element. You need to add !important to the size of the image to give it priority:

Code:
.autoIMG {
	text-indent: 0;
	text-align: center;
	max-height: 32em;
	margin: 0;
	}
.autoIMGimage {
	width: auto;
        max-height: 32em !important;
	margin: 0 auto;
	display: block;
	}
Of that way, the height of the image will be ten times the height of the font.



The issue is with your original code; I didn't change anything to reproduce the problem.
Perfect! Thank you!

(Also, I meant what was changed from the first time you looked at it in the readium plugin (when it worked) and when you looked at my code straight up (which was failing), and it's the "!important").
ElMiko is online now   Reply With Quote
Reply

Tags
image height, image scaling


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 06:30 PM.


MobileRead.com is a privately owned, operated and funded community.