![]() |
#1 |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 39
Karma: 20178
Join Date: Jun 2013
Device: Kobo Touch
|
XHTML img shrinked in tables only on ereader
I have this basic XHTML file, with a table that displays images in the first column (images size is roughly 64x64 pix) and some text in the second column.
Code:
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"> <head> <link href="../Styles/style.css" rel="stylesheet"/> </head> <body> <table> <tbody> <tr> <td><img src="../Images/A.png"/></td> <td><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sapien tortor, malesuada convallis mi quis, mattis porta eros. Integer sed massa et felis aliquam interdum eget sed massa. Vestibulum luctus, lacus in posuere consectetur, neque orci maximus lectus, tristique aliquam tortor nulla id lacus. Sed tempor auctor felis at vulputate.</p></td> </tr> <tr> <td><img src="../Images/D.png"/></td> <td><p>Donec pretium dapibus felis at vestibulum. Morbi posuere mauris ac facilisis sollicitudin. Praesent iaculis mauris molestie ante cursus, sit amet ornare velit viverra. Cras dictum sollicitudin erat, mollis tempus orci hendrerit sit amet.</p></td> </tr> </tbody> </table> </body> </html> I added the file to an epub. Opening it with an ebook reader (Calibre default one) I see everything like in the browser (i.e. full size images). I've uploaded the epub on my erader device (an old Kobo Touch). Here images are shrinked to a very small size. Why is this happening? Could it be an ereader problem? Likely. Any HTML/css trick to force full size? I've tried to add this to the css file Code:
table img { height: 100%! important; } |
![]() |
![]() |
![]() |
#2 |
Still reading
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,698
Karma: 103837201
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
|
Use width?
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,312
Karma: 20171571
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
|
|
![]() |
![]() |
![]() |
#4 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,641
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Give to the table a "width", for example by adding in your .css file something like:
Code:
table.mytable { width: 100%; /*(or whatever the width you wish)*/ } Code:
td.first { width: 33%; /*(or whatever the width you wish)*/ } Code:
td.first img { width: 100%; } Code:
<table class="mytable"> <tbody> <tr> <td><img src="../Images/A.png"/></td> <td><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sapien tortor, malesuada convallis mi quis, mattis porta eros. Integer sed massa et felis aliquam interdum eget sed massa. Vestibulum luctus, lacus in posuere consectetur, neque orci maximus lectus, tristique aliquam tortor nulla id lacus. Sed tempor auctor felis at vulputate.</p></td> </tr> <tr> <td class="first"><img src="../Images/D.png"/></td> <td><p>Donec pretium dapibus felis at vestibulum. Morbi posuere mauris ac facilisis sollicitudin. Praesent iaculis mauris molestie ante cursus, sit amet ornare velit viverra. Cras dictum sollicitudin erat, mollis tempus orci hendrerit sit amet.</p></td> </tr> </tbody> </table> |
![]() |
![]() |
![]() |
#5 |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 39
Karma: 20178
Join Date: Jun 2013
Device: Kobo Touch
|
Ok, maybe I should have clarified beforehand why I used "height" instead of "width"...
When I set Code:
width: 100%; I get small images even in browser. Setting Code:
height: 100%; Anyway, I've tested these options, with various results (none is ok); Code:
width: 100%; Code:
height: 100%; Code:
height: 100%; width: 100%; Regarding @RbnJrg hint, I prefer a more generic approach. I can have tables, with the same format as mytable, but have just text in the first column. So, I don't want to set a specific width for the first column. I want it to stretch given the image width (if any). This way I can avoid class-ification of the tds that contain images. NOTE: in my former example I stated that the images are shrinked (in both width and height) when setting "height" attribute in CSS. I've noticed a typo in my CSS Code:
height: 100%! important; Code:
height: 100% !important; |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,031
Karma: 91577715
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
|
What you are doing seems like a wrong approach. Specifying an image width or height in percent says to make it a percentage of the enclosing block, the table cell in this case. The image will end up being sized based on the other content in the table, not based on the image itself.
You should instead do something like set the table cells to each be a certain percentage of the screen width and then have the image take up 100% of the enclosing cell width. Last edited by jhowell; 09-28-2020 at 12:46 PM. |
![]() |
![]() |
![]() |
#7 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,641
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
That's correct and was the central point of my aproximation, but it seems that the OP doesn't understand how images are displayed.
|
![]() |
![]() |
![]() |
#8 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,641
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
![]() And how many tables with the same format as "mytable" you have? Give those tables another class name and your troubles are ended. Regex is your friend to do changes. Last edited by RbnJrg; 09-28-2020 at 03:56 PM. |
|
![]() |
![]() |
![]() |
#9 |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 39
Karma: 20178
Join Date: Jun 2013
Device: Kobo Touch
|
I admit I'm not very expert in HTML/CSS. I hoped for some "don't rescale" attribute. Looks like there's none.
I'm writing a (python) script that converts several fancy HTML pages in more minimal XHTML for ereaders. Since the tables are kinda random with their content, I preferred a "generic" approach. Looks like I have to add an extra check that class-ify a table if it has images in the first column. Will experiment with that. Thanks |
![]() |
![]() |
![]() |
Tags |
css, epub, xhtml |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
4.11.1 right click img in editor to edit img | rjwse@aol.com | Calibre | 1 | 02-21-2020 09:29 PM |
Some files.html & toc.xhtml (also Cover.xhtml) | chaot | Workshop | 23 | 02-13-2017 12:20 PM |
New Kindle Ereader 5.8.2 firmware improve tables experience | Julius Caesar | Amazon Kindle | 19 | 08-24-2016 05:56 AM |
<img longdesc= | traskilajussi | EPUBReader | 3 | 02-23-2011 08:15 AM |
vfat.img | pewterbot9 | enTourage Archive | 11 | 12-29-2010 06:41 PM |