Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old Yesterday, 10:16 AM   #1
icearch
Connoisseur
icearch began at the beginning.
 
Posts: 89
Karma: 10
Join Date: Nov 2025
Device: none
Using absolute units in img width tends to fail

Using absolute units in img width tends to fail in a lot of reader apps. They simply ignore that and stretch the img to 100% or original size.

Resizing img in advance kinna hurts it's quality, and pretty annoying. Any good way to fix this?
icearch is offline   Reply With Quote
Old Yesterday, 10:31 AM   #2
j.p.s
Grand Sorcerer
j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.j.p.s ought to be getting tired of karma fortunes by now.
 
Posts: 5,938
Karma: 106187745
Join Date: Apr 2011
Device: pb360
Why not use %, especially since you don't know the PPI of the display?
j.p.s is offline   Reply With Quote
Old Yesterday, 10:53 AM   #3
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: 82,061
Karma: 150871335
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
One other option is if the absolute units make the image smaller then it is, resize the image to that size. Then you don't have to use absolute units.
JSWolf is offline   Reply With Quote
Old Yesterday, 11:36 AM   #4
icearch
Connoisseur
icearch began at the beginning.
 
Posts: 89
Karma: 10
Join Date: Nov 2025
Device: none
Quote:
Originally Posted by j.p.s View Post
Why not use %, especially since you don't know the PPI of the display?
Using % can have some other problems in certain reader app, but a lot more acceptable. But I prefer learning more things so I'm asking anyway.

As to ppi, I don't think that's how it's working? px is 1/96 in, have nothing to do with pixel so nothing to do with ppi.
icearch is offline   Reply With Quote
Old Yesterday, 11:49 AM   #5
slm
(who/what)
slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.slm ought to be getting tired of karma fortunes by now.
 
Posts: 536
Karma: 5065098
Join Date: Feb 2003
Device: Kindle: Voyage,PW1,KOA, Kobo: Clara Colour, Nook GLP, Pocketbook verse
Quote:
Originally Posted by icearch View Post
px is 1/96 in, have nothing to do with pixel so nothing to do with ppi.
Not quite: from https://www.w3schools.com/cssref/css_units.php:
Pixels (px) are relative to the viewing device. For low-dpi devices, 1px is one device pixel (dot) of the display. For printers and high resolution screens 1px implies multiple device pixels
I don't know that many modern readers or screens have less than 96ppi, so in practice, I guess, 1/96 in is likely to be accurate.
slm is online now   Reply With Quote
Old Yesterday, 01:39 PM   #6
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,584
Karma: 21743811
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by j.p.s View Post
Why not use %, especially since you don't know the PPI of the display?
Because if you want 3cm, % doesn't help. You don't know the ppi, and you don't know the screen size. But if you do know you want 3cm, you should be able to say 3cm, and the device should know what to do with it.
Jellby is offline   Reply With Quote
Old Yesterday, 08:04 PM   #7
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,457
Karma: 20534347
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
This is not perfect, but it seems to cover most cases:

1) try an svg wrapper. That works great for a full screen image. With a little more advanced settings you can make it work great for a less than full screen as well...

if that doesn't work - for whatever reason:

2) use % of your screen size but put a maximum on it to prevent pixelation/fuzziness on a large screen. eg.
Code:
  img {width:50%; max-width:600px}

You may need to use height instead of width instead depending on your image aspect ratio and/or if the screen is in landscape or portrait mode (use media queries). eg.
Code:
<div class="image">
  img {height:50%; max-height:800px}
</div>
But remember you will probably need to supply a container (<div>) so it can determine what height to use as the percentage used is the % of the container...(what is the height of an auto-scroll page?)...
I set the max height/width using the corresponding dimensions of the image. If it is 600x800 then I use max-width:600px or max-height:800px. This is not perfect, as alluded to above, but it gets it close enough to prevent the over pixelation.

BTW, the svg wrapper handles all those issues for you automagically.
Turtle91 is offline   Reply With Quote
Old Yesterday, 11:18 PM   #8
icearch
Connoisseur
icearch began at the beginning.
 
Posts: 89
Karma: 10
Join Date: Nov 2025
Device: none
Quote:
Originally Posted by Turtle91 View Post

2) use % of your screen size but put a maximum on it to prevent pixelation/fuzziness on a large screen. eg.
Code:
  img {width:50%; max-width:600px}

You may need to use height instead of width instead depending on your image aspect ratio and/or if the screen is in landscape or portrait mode (use media queries). eg.
Code:
<div class="image">
  img {height:50%; max-height:800px}
</div>
But remember you will probably need to supply a container (<div>) so it can determine what height to use as the percentage used is the % of the container...(what is the height of an auto-scroll page?)...
.
I have tried this last night, using a div to contain it, set it to 5em height, and 100% height for img. Works great in sigil, but still fails in reader.
icearch is offline   Reply With Quote
Old Today, 12:46 AM   #9
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,457
Karma: 20534347
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
Did you try #1 option, using an svg wrapper??

Also, what reader are you using?? Some of them are so bad and non-standards compliant, it isn’t worth trying to cater to them.

Last edited by Turtle91; Today at 12:48 AM.
Turtle91 is offline   Reply With Quote
Old Today, 01:23 AM   #10
icearch
Connoisseur
icearch began at the beginning.
 
Posts: 89
Karma: 10
Join Date: Nov 2025
Device: none
Quote:
Originally Posted by Turtle91 View Post
Did you try #1 option, using an svg wrapper??

Also, what reader are you using?? Some of them are so bad and non-standards compliant, it isn’t worth trying to cater to them.
I think up #2 myself and tried it before bed. Then this morning I saw your post. I am not at my pc now.

Haven't tried #1, because haven't looking into svg wrapper deeply.

A heap amount reader apps have trouble, Readest, Moon +, FB reader. And it might have something to do with my setting.

So I think the better way might be resize logo to small pic beforehand, this also controls the file size.

I will looking into svg wrapper when I have more free time.
icearch is offline   Reply With Quote
Old Today, 06:24 AM   #11
Quoth
Still reading
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: 15,311
Karma: 113000119
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
Quote:
Originally Posted by Jellby View Post
Because if you want 3cm, % doesn't help. You don't know the ppi, and you don't know the screen size. But if you do know you want 3cm, you should be able to say 3cm, and the device should know what to do with it.
But that won't work on lots of things. Percent is better for larger images. Smaller ones (maybe a little logo, fluerion or QR code) can work even with pt (sometimes that scales with user scaling font) or px.

Actual physical units are only reliable for PDF, which should use them.
Quoth is offline   Reply With Quote
Old Today, 07:44 AM   #12
icearch
Connoisseur
icearch began at the beginning.
 
Posts: 89
Karma: 10
Join Date: Nov 2025
Device: none
I tried the svg wrapper in sigil cover (using my phone), I have to say not very successful.

Something working on one app does not working on others. Some app can't render the svg ones at all. Which is strange because the cover can render correctly.

Need more learning and experimenting.

Last edited by icearch; Today at 07:51 AM.
icearch is offline   Reply With Quote
Old Today, 08:06 AM   #13
icearch
Connoisseur
icearch began at the beginning.
 
Posts: 89
Karma: 10
Join Date: Nov 2025
Device: none
I have to say it's getting more tedious than resizing pic
.
icearch is offline   Reply With Quote
Old Today, 09:15 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: 82,061
Karma: 150871335
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Don't forget to test your images on different screens such as a cell phone and eInk (at least 6"), That way you'll know how well the images display.

Some software allows you to zoom the images, but not all.

Last edited by JSWolf; Today at 09:17 AM.
JSWolf is offline   Reply With Quote
Old Today, 10:13 AM   #15
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,909
Karma: 8987599
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by icearch View Post

A heap amount reader apps have trouble, Readest, Moon +, FB reader. And it might have something to do with my setting.
Your issue is due to the apps you are using. Moon +, FB reader are awful; Readest is a nice app but perhaps you haven't configured it correctly and you're allowing the epub's css code to be overwritten with your personal preferences (there are some things in Readest that are not yet properly implemented). Open your epub and test your code with Cantook, Reasily, Lithium, Kobo for Android, PocketBook, Infinity Reader, BookFusion.
RbnJrg is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
css if img aspect-ratio >1/1 width:100%, otherwise width:50% rjwse@aol.com Editor 0 03-19-2021 08:41 AM
4.11.1 right click img in editor to edit img rjwse@aol.com Calibre 1 02-21-2020 10:29 PM
change img or box width for multi-column in calibre viewer rjwse@aol.com Calibre 2 12-02-2019 11:48 AM
Zero-width non joiner vs. zero width space? Phssthpok Editor 3 09-06-2015 04:45 AM
WIDTH and HEIGHT in <img> tags Pablo Sigil 3 06-10-2010 06:37 PM


All times are GMT -4. The time now is 10:34 PM.


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