|
|
#1 |
|
Connoisseur
![]() Posts: 90
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? |
|
|
|
|
|
#2 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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?
|
|
|
|
|
|
#3 |
|
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 82,066
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.
|
|
|
|
|
|
#4 | |
|
Connoisseur
![]() Posts: 90
Karma: 10
Join Date: Nov 2025
Device: none
|
Quote:
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. |
|
|
|
|
|
|
#5 | |
|
(who/what)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 536
Karma: 5065098
Join Date: Feb 2003
Device: Kindle: Voyage,PW1,KOA, Kobo: Clara Colour, Nook GLP, Pocketbook verse
|
Quote:
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.
|
|
|
|
|
|
|
#6 |
|
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,584
Karma: 21743811
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
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.
|
|
|
|
|
|
#7 |
|
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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>
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. |
|
|
|
|
|
#8 | |
|
Connoisseur
![]() Posts: 90
Karma: 10
Join Date: Nov 2025
Device: none
|
Quote:
|
|
|
|
|
|
|
#9 |
|
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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; Yesterday at 12:48 AM. |
|
|
|
|
|
#10 | |
|
Connoisseur
![]() Posts: 90
Karma: 10
Join Date: Nov 2025
Device: none
|
Quote:
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. |
|
|
|
|
|
|
#11 | |
|
Still reading
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 15,311
Karma: 113000119
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
|
Quote:
Actual physical units are only reliable for PDF, which should use them. |
|
|
|
|
|
|
#12 |
|
Connoisseur
![]() Posts: 90
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; Yesterday at 07:51 AM. |
|
|
|
|
|
#13 |
|
Connoisseur
![]() Posts: 90
Karma: 10
Join Date: Nov 2025
Device: none
|
I have to say it's getting more tedious than resizing pic
. |
|
|
|
|
|
#14 |
|
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 82,066
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; Yesterday at 09:17 AM. |
|
|
|
|
|
#15 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,909
Karma: 8987599
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
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.
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
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 |