|
![]() |
|
Thread Tools | Search this Thread |
![]() |
#1 |
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 166
Karma: 474196
Join Date: Jan 2011
Location: Canada
Device: Kobo Libra 2
|
Resizing images, retaining width-height rato, and only if necessary.
Hi, folks.
I'm putting together an ebook (epub for kobo glo) and it has a lot of scanned images, diagrams, etc, that must be large to be read or otherwise appreciated, but in some cases (or, should I open the document with a smaller-screened ereader), I'd like the image to be automatically scaled down to fit the screen width or height (whichever it needs to do to fully fit on screen). I've looked through a lot of topics here, on stackoverflow, etc, but there seems to be conflicting opinions regarding width vs max-width and so forth, so I figured I'd just ask and see what happens. So, to lay out what I need: -Image dimensions must be preserved, i.e., an image of 800x600px must retain a 4:3 aspect ratio (obviously, I don't want the image to be stretched or smeared) -If resizing is necessary, it should only be reduced in size. I don't need the image to be blown up to fit a screen; only shrunk down to fit. -The image must fit fully onto the screen so that either the horizontal or vertical sides of the image touch the sides of the ereader margins. Any help would be appreciated. Thanks in advance. |
![]() |
![]() |
![]() |
#2 |
mostly an observer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,518
Karma: 987654
Join Date: Dec 2012
Device: Kindle
|
I don't have a Kobo reader; my only experience is with Kindles, Fire tablets, and Nooks.
On the first-generation Kindles, images will be full screen unless they are very small to begin with. There's no way to control that. I think the same is true of Kindle for iPad. On the tablets, the reader can zoom any image (within reason) but otherwise the higher the resolution, the smaller the image, unless one uses a width="100%" instruction in the html. BUT full screen means the dimensions of the text, with whitespace all around. A zoomed image will indeed reach to the edge of the screen, at least in one dimension. I have never seen a distorted image, even when I use width="100%" and hold the tablet in landscape mode. |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
I use:
Quote:
That will fill the screen without changing the aspect ratio if the image is larger than the screen. And smaller images will be shown centred on the screen at their natural size. |
|
![]() |
![]() |
![]() |
#4 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,313
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
|
I also use SVG on any images that I want to take up a full screen by itself. The reading app I use (MARVIN) properly handles SVG but I've heard some kindles ignore SVG after the cover (??) and some devices might not support SVG at all (???). If that is a concern for you, or if you just want to insert an image in the flow of text, you can use the following:
Code:
<div class="whatever"><img alt="" src="../Images/example.jpg" /></div> with CSS: .whatever {width:100%; max-width:9999px} max-width limits the width of the div to a certain number. If you set that value to the actual width of your image in pixels, then the image will not be stretched and will not blur on larger screens. If you just use width then aspect ratio is kept for all images. The problems I find are when people try and set width AND height (ie width:100%; height:100%). That usually causes stretching and distortion. Part of the problem is that not all devices/apps define height the same way... but that's a whole 'nuther topic. Cheers! |
![]() |
![]() |
![]() |
#5 | |
mostly an observer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,518
Karma: 987654
Join Date: Dec 2012
Device: Kindle
|
Quote:
Does min-width also work in a situation like that? Say width:30%; min-width:130px? |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,313
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
|
Quote:
.whatever {width:15%; min-width:30px; max-width:120px} to ensure the image is not too small that you can't see it, or too large that it gets all blurry, otherwise it is 15% of the screen (container) width. Caveat: I use Sigil and Calibre to edit, and Marvin to read. I can't speak to supportability with other devices...but the html/css is sound. |
|
![]() |
![]() |
![]() |
#7 |
mostly an observer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,518
Karma: 987654
Join Date: Dec 2012
Device: Kindle
|
Thanks again. AFAIK, that works on every Kindle except K1, K2, and DX (and, some say, early builds of the K3 Keyboard). Oh, and Kindle apps on some or all iPads, though weirdly I have no problem with my iPhone 4.
|
![]() |
![]() |
![]() |
#8 |
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 166
Karma: 474196
Join Date: Jan 2011
Location: Canada
Device: Kobo Libra 2
|
Thanks for the suggestions, everyone! Its too bad that this stuff is so non-standard. I'm always nervous when fixing up ebooks that what I'm doing will work on my current reader, but not the next one down the line.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Kindle previewer - images not resizing to page width | goodmorningjulie | Amazon Kindle | 0 | 04-23-2015 05:47 AM |
resizing in-line images | pdurrant | ePub | 12 | 08-16-2013 04:08 AM |
Flightcrew : is px for the height/width forbidden ? | NicolasR | Sigil | 2 | 02-11-2011 03:51 AM |
WIDTH and HEIGHT in <img> tags | Pablo | Sigil | 3 | 06-10-2010 05:37 PM |
Retaining images/figures in RTF/DOC derived from PDF? | haguilar | Sony Reader | 4 | 12-06-2007 03:26 PM |