Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 09-23-2023, 11:36 PM   #1
Vanguard3000
Groupie
Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.
 
Posts: 152
Karma: 474196
Join Date: Jan 2011
Location: Ottawa
Device: Kobo Aura H2O
Image sizeing no longer working on some platforms?

*"sizing"

I feel like I'm going crazy here. I recently created an ebook with images in the <h2> headers (an alien language as chapter number), and styled it as I have many times before, with something like:

Code:
<h2><img style="height: 1em;max-width: 50%; object-fit: contain;" src="../Images/ch01.jpg"/><br/>Title</h2>
(I initially had this as a css class but it's the same either way). Everything looked fine in Sigil's preview pane as well as Calibre's book viewer, but on my Kobo Libra 2 (latest firmware) and MoonReader+ for Android, the image is full-size (it was a large image so it basically filled the screen). Other CSS classes and styles, such as font sizes, alignments, etc. work fine.

I've tried playing around with the specific size values, different images, and creating a brand new epub to no avail, and it's freaking me out a bit because I've been doing this for years and and can't see what I'm missing.

See an attached test epub and a screenshot of what it looks like in Moon+ reader. Thanks in advance for any help.
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20230923-231742.jpg
Views:	84
Size:	330.2 KB
ID:	203933  
Attached Files
File Type: epub test3.epub (81.3 KB, 38 views)

Last edited by Vanguard3000; 09-24-2023 at 12:10 AM.
Vanguard3000 is offline   Reply With Quote
Old 09-24-2023, 04:43 AM   #2
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,164
Karma: 85874891
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
Use a class and CSS rather than an Inline style anyway.
If you want correct aspect ratio and a percentage

<h2><img class="ch-image" src="../Images/ch01.jpg"/><br/>Title</h2>

.h2 {
// no left and right margins (or padding), but do center and set font & size
}

.ch-image {
image-width: 50%;
image-height: auto
}

Last edited by Quoth; 09-24-2023 at 04:46 AM.
Quoth is offline   Reply With Quote
Advert
Old 09-24-2023, 10:42 AM   #3
Vanguard3000
Groupie
Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.
 
Posts: 152
Karma: 474196
Join Date: Jan 2011
Location: Ottawa
Device: Kobo Aura H2O
As I mentioned in my initial post, I had it as a class originally, but it makes no difference to the problem I'm seeing so I simplified my example by inlining it.

In my actual book, I'm overriding h2 to center and style the text, then classing the image via "h2 > img".
Vanguard3000 is offline   Reply With Quote
Old 09-25-2023, 06:00 AM   #4
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,164
Karma: 85874891
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
Quote:
Originally Posted by Vanguard3000 View Post
As I mentioned in my initial post, I had it as a class originally, but it makes no difference to the problem I'm seeing so I simplified my example by inlining it.

In my actual book, I'm overriding h2 to center and style the text, then classing the image via "h2 > img".
Yes, but likely the H2 and image CSS was wrong.
Quoth is offline   Reply With Quote
Old 09-25-2023, 12:58 PM   #5
Vanguard3000
Groupie
Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.
 
Posts: 152
Karma: 474196
Join Date: Jan 2011
Location: Ottawa
Device: Kobo Aura H2O
Quote:
Originally Posted by Quoth View Post
Yes, but likely the H2 and image CSS was wrong.
If that were the case, the inline styling I've provided as an example ought to work. In any case, here is the stylesheet info from the actual file for reference:

Code:
h2,h3,h4 {
  page-break-after: avoid;
}

h2 {
  text-align: center;
  font-style: italic;
  font-size: 2.5em;
  font-weight: normal;
}

h2 > img {
  height: 1em;
  object-fit: contain;
}
Note that the h2 styling to the text (centred justification and italicized style) work as intended, so the stylesheet is linked correctly as far as I can tell.
Vanguard3000 is offline   Reply With Quote
Advert
Old 09-25-2023, 04:30 PM   #6
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,164
Karma: 85874891
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
But your image style and class are both wrong.

You either set height and and width to px (never em or rem), or set one to auto and the other to a %

Anything else is unreliable.

Like
.ch-image {
width: 50%;
height: auto
}

Also don't use h2 > img

"object-fit: contain" will not be reliable and will distort as height: 1em

Last edited by Quoth; 10-01-2023 at 02:12 PM. Reason: mistake
Quoth is offline   Reply With Quote
Old 09-25-2023, 05:06 PM   #7
azimuth
Enthusiast
azimuth plays well with othersazimuth plays well with othersazimuth plays well with othersazimuth plays well with othersazimuth plays well with othersazimuth plays well with othersazimuth plays well with othersazimuth plays well with othersazimuth plays well with othersazimuth plays well with othersazimuth plays well with others
 
Posts: 33
Karma: 2538
Join Date: Aug 2023
Location: NW US
Device: none
The heading elements <h_> by default is block-level, which means it spreads full line width. It can be assumed that Moon+ is merely holding to the standards expected for the <h2> element and making your image also spread full line width regardless of your CSS.
And...you likely don't want the image to be 1em tall - that's the height of the words on that line, and your image is a fully detailed designed image that can only be viewed when its larger than 1em.
So...set the image outside of the <h2> element, and use the <img> tag as Quoth suggested: width: 50%; height: auto; .
Read the following at Mozilla.

MDN heading

MDN block image
azimuth is offline   Reply With Quote
Old 09-26-2023, 12:01 PM   #8
nabsltd
Evangelist
nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.
 
Posts: 417
Karma: 6913952
Join Date: Aug 2013
Location: Hamden, CT
Device: Kindle Paperwhite (11th gen), Scribe
Quote:
Originally Posted by Quoth View Post
You either set height and and width to px (never em or rem), or set one to auto and the other to a %
Agreed about setting either height/width to a value and the other to auto, as this maintains aspect ratio.

But, "em" is a perfectly valid way to declare the value, especially for height, if you want the image to scale with user font size changes. For an image that shouldn't change size with font size changes, then px or % would be correct.
nabsltd is offline   Reply With Quote
Old 09-26-2023, 12:28 PM   #9
Vanguard3000
Groupie
Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.Vanguard3000 ought to be getting tired of karma fortunes by now.
 
Posts: 152
Karma: 474196
Join Date: Jan 2011
Location: Ottawa
Device: Kobo Aura H2O
Quote:
Originally Posted by Quoth View Post
You either set height and and width to px (never em or rem)
The sample you provided worked as it should (after removing the "image-" the attributes), but I specifically want the image to scale with the h2 text as it's technically a part of the chapter title, which is why I was using em for the height. Is there an alternative that satisfies that requirement?

Quote:
Originally Posted by Quoth View Post
Also don't use h2 > img
How come? Is that a limited-compatibility thing?

Quote:
Originally Posted by Quoth View Post
"object-fit: contain" will not be reliable and will distort as height: 1em
Again - how come? From what I can tell this is a common way to ensure an aspect ratio-respecting fit for an image.

In any case, thanks for your help so far. I'm self-taught with this stuff so if there are ways I can improve I'm happy to learn them.

Quote:
Originally Posted by azimuth View Post
The heading elements <h_> by default is block-level, which means it spreads full line width.
I experimented with this by changing the background color, and I would have thought that adding a <span> around the image would help - and it does with my debug background color but not with the image size.

Quote:
Originally Posted by azimuth View Post
And...you likely don't want the image to be 1em tall - that's the height of the words on that line
It is indeed what I want. The image in my example is a placeholder; the actual one is from a made-up language's number system, and so is technically part of the chapter's title (for the ToC I would use standard Arabic numerals). I don't think I was super clear about this in my original post but I've uploaded a new test file and image to better illustrate this. Thank you for your help so far.

--

I guess the crux of my issue is this: Is there a way to add an image within a paragraph or header block that scales properly with the text? I feel like this shouldn't be a difficult thing but it seems to elude me right now.
Attached Thumbnails
Click image for larger version

Name:	Untitled-1.jpg
Views:	43
Size:	6.0 KB
ID:	203964  
Attached Files
File Type: epub flarb.epub (16.0 KB, 38 views)

Last edited by Vanguard3000; 09-26-2023 at 12:50 PM.
Vanguard3000 is offline   Reply With Quote
Old 09-26-2023, 07:05 PM   #10
azimuth
Enthusiast
azimuth plays well with othersazimuth plays well with othersazimuth plays well with othersazimuth plays well with othersazimuth plays well with othersazimuth plays well with othersazimuth plays well with othersazimuth plays well with othersazimuth plays well with othersazimuth plays well with othersazimuth plays well with others
 
Posts: 33
Karma: 2538
Join Date: Aug 2023
Location: NW US
Device: none
Some web link solutions (for Epub3.0) below.
Epub2.0 won't allow CSS min/max, or calc(), or @supports, or @media. But with a bit of reading there you might find an alternate workable option. Moon+ App was a stumbling block even for me and involved additional CSS trickery (on a different CSS issue).

Simplified fluid font size:
CSS-tricks1
Viewport fluid font size:
CSS-tricks2
azimuth is offline   Reply With Quote
Old 09-27-2023, 05:56 AM   #11
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 74,015
Karma: 129333114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
For images you want to scale, use SVG if you can so when it does scale, it will look OK.
JSWolf is offline   Reply With Quote
Old 09-27-2023, 06:45 AM   #12
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,164
Karma: 85874891
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
Set height and width (proportionately) in pt or em (1em = 12pt) for images that scale with user selected font size. But only works on some devices/apps. Unreliable!

Normally px should be used and images should not attempt to rescale with user font size selection.
Quoth is offline   Reply With Quote
Old 09-27-2023, 06:48 AM   #13
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,164
Karma: 85874891
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
Quote:
Originally Posted by JSWolf View Post
For images you want to scale, use SVG if you can so when it does scale, it will look OK.
Yes. but there is no way to reliably autoscale with user changing font size. It sometimes works. I agree that if width or height is a % and the other is auto, then SVG is good, but for Amazon KDP simply downscaling a larger png or jpg (no transparency) works better.
Quoth is offline   Reply With Quote
Old 09-27-2023, 06:56 AM   #14
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 74,015
Karma: 129333114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by Quoth View Post
Set height and width (proportionately) in pt or em (1em = 12pt) for images that scale with user selected font size. But only works on some devices/apps. Unreliable!

Normally px should be used and images should not attempt to rescale with user font size selection.
The problem with using px is that unless you know the screen the ePub is going to be read on, it could maybe be too large or too small.
JSWolf is offline   Reply With Quote
Old 09-27-2023, 12:56 PM   #15
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by JSWolf View Post
The problem with using px is that unless you know the screen the ePub is going to be read on, it could maybe be too large or too small.
No, because a CSS px is an absolute unit equal to 1/96 inch. It is not a screen pixel.

Another thing, of course, is whether the reading application knows this and complies with it, but that's the realm of bugs and quirks.
Jellby is online now   Reply With Quote
Reply

Tags
image, scale, size


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Netflix No Longer Working!!!! pokee Kobo Tablets 11 11-12-2011 11:40 PM
Calibre No Longer Working hmf Calibre 5 06-12-2011 12:45 AM
Help! Image Consistency across platforms Souldor_MT General Discussions 1 04-01-2011 02:50 PM
Fetch cover image from server no longer working ki5ck Calibre 2 02-09-2009 07:09 PM


All times are GMT -4. The time now is 02:41 PM.


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