Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > Kindle Formats

Notices

Reply
 
Thread Tools Search this Thread
Old 02-28-2012, 03:50 PM   #1
taskforsome
Junior Member
taskforsome began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Sep 2010
Device: Calibre
Lightbulb Problem with images from epub to mobi

Hi all,

I recently converted an epub (which validates through epubcheck without problems) to mobi with Kindle Previewer.

I used relative percentages in the <img> tags, but mobi format resizes all images to fit the whole width of the screen. In the original epub I have the following code for the images:

<div>
<p class="image"><img src="xxx"/></p>
<p class="caption">Caption text</p>
</div>

The problem is that in mobi the image and the caption are not together; in the most cases the image resize to fit screen (width or height) and the caption appears in the next page alone.

How could I resolve that?

Thanks
taskforsome is offline   Reply With Quote
Old 02-28-2012, 04:42 PM   #2
dwig
Guru
dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.
 
dwig's Avatar
 
Posts: 984
Karma: 1382338
Join Date: Dec 2004
Location: Paradise (Key West, FL)
Device: Current:Dell Venue 8 Pro, Kindle 3/WiFi - Retired:Clie UX50, T415, ...
Quote:
Originally Posted by taskforsome View Post
...
I used relative percentages in the <img> tags,...
...but mobi format resizes all images to fit the whole width of the screen.
Wrong. "mobi format" is not doing this. Your chosen converter, KindleGen (via Previewer), is doing it.

If you want to use KindleGen for the conversion you should spec each image with the desired pixel size for width and height explicitly, inside of the <img> tag itself.

Quote:
The problem is that in mobi the image and the caption are not together...
There is no good way to prevent this. No matter what you do, a text caption may render on the next screen when the image is too near the bottom of a screen. You can use a good image editor and create images with "text" for the caption in the image itself. This fixes the current issue, but prevents the reader from scaling the "text" larger or smaller when the user alters their device's base font size. My edition of "The Atlantic River" uses this technique. Most captions are fine in the regular text flow, but some readers may need to "click" on the images to display them full screen (Kindle version only) to make the caption text more readable.
dwig is offline   Reply With Quote
 
Advertisement
Old 02-28-2012, 04:42 PM   #3
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 9,424
Karma: 43260000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I've only ever had consistent luck controlling image size (using Kindlegen/Kindle Previewer) when I hard-code the sizes in the image tag:
<img src="../Images/my_picture.gif" height="120px" width="80px" />

EDIT: just as dwig said while i was fat-fingering my response.
DiapDealer is offline   Reply With Quote
Old 02-29-2012, 04:23 AM   #4
taskforsome
Junior Member
taskforsome began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Sep 2010
Device: Calibre
Thanks dwig and DiapDealer.

So, if I undrestood you both well, it is no possible to assign a fluid with to images with Kindlegen, isn't it?
taskforsome is offline   Reply With Quote
Old 02-29-2012, 08:13 AM   #5
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 9,424
Karma: 43260000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by taskforsome View Post
Thanks dwig and DiapDealer.

So, if I undrestood you both well, it is no possible to assign a fluid with to images with Kindlegen, isn't it?
Across all devices, no. If you know you'll be designing an ebook specifically for the Kindle Fire (and anything else that suports the KF8 format) you can specify CSS image width and height attributes. But if one is a fixed percentage, the other needs to be set to auto in order to preserve the aspect ratio of the image.

You should be able to jump through some hoops and specify the width, height attributes (in pixels) in the (x)html for the normal eInk kindle devices, and then override those html attributes with a CSS media query that would only apply to devices that support the KF8 format (like the Kindle Fire).

Code:
@media amzn-kf8 {
  img.myclass {width:80%; height:auto}
}
Kindlegen 2 will ignore that css when building the normal mobi portion, but should use the CSS (that should override html attributes) to style images of the class "myclass" when building the KF8 portion.

I say should be possible because that's the way I'm interpreting the new Kindle Publishing Guidelines. I've not tested that case specifically, but I know the media queries can be used to specify different CSS for different devices. And CSS is supposed to take precedence over html attributes.

I apologize if that was more information than you were looking for.

Last edited by DiapDealer; 02-29-2012 at 08:19 AM.
DiapDealer is offline   Reply With Quote
Old 02-29-2012, 08:50 AM   #6
taskforsome
Junior Member
taskforsome began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Sep 2010
Device: Calibre
Thanks, DiapDealer. There's never too much information...

Then I wonder if I could apply your suggestion in the ebooks I'm making. I design the original for epub, so I use fluid width for all images: the result is valid in ADE, for example, or in my Sony PRS-T1.

But my client wants to convert these epubs in mobi in order to sell them in Amazon. We've decided not to change the original epub (inserting fixed measures for images), but, according to your comments, it'd be possible to insert a media query for KF8 supported devices, isn't it?

And another question: it'd be possible to maintain image and caption together (in .mobi format) using tables, for example? Or another resoruce...
taskforsome is offline   Reply With Quote
Old 02-29-2012, 09:48 AM   #7
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 9,424
Karma: 43260000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by taskforsome View Post
But my client wants to convert these epubs in mobi in order to sell them in Amazon. We've decided not to change the original epub (inserting fixed measures for images), but, according to your comments, it'd be possible to insert a media query for KF8 supported devices, isn't it?
Absolutely. I tend to use completely separate CSS files for epub/mobi/KF8. That way, I can use a "master" css file to import the relevant stylesheet. I can then comment out the Amazon stuff (and remove the extraneous css files(s) if necessary) when supplying an ePub... and vice versa when building a mobi.

In the main css file (that every html page links to):
Code:
@import url(../Styles/epub.css);
/* @import url(../Styles/mobi.css) amzn-mobi;
@import url(../Styles/epub.css) amzn-kf8; */
I can then comment out the first line and uncomment the next two when building the MOBI with kindlegen.

Quote:
Originally Posted by taskforsome View Post
And another question: it'd be possible to maintain image and caption together (in .mobi format) using tables, for example? Or another resoruce...
I'm not sure. That's always going to be an issue in reflowable documents. Fixed-Layout KF8's can place captions directly on an image, but I don't think you can mix and match: an ebook is either Fixed-Layout or reflowable. Tables may work, but with MOBIs, bad things tend to happen when tables are used to achieve a certain "layout." Tables should only really be used when you have tabular data to present. Users can often easily "break" table layouts by increasing font-sizes (when they contain text).
DiapDealer is offline   Reply With Quote
Old 03-01-2012, 04:46 AM   #8
taskforsome
Junior Member
taskforsome began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Sep 2010
Device: Calibre
Thanks again.

A last question. Which are the most common differences/elements in order to be considered in MOBI format? I mean, like the trouble with images...
taskforsome is offline   Reply With Quote
Old 03-01-2012, 01:05 PM   #9
DaleDe
Grand Sorcerer
DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.
 
DaleDe's Avatar
 
Posts: 9,744
Karma: 5072196
Join Date: Aug 2007
Location: Grass Valley, CA
Device: EB 1150, EZ Reader, Literati, iPad 2
Quote:
Originally Posted by taskforsome View Post
Thanks again.

A last question. Which are the most common differences/elements in order to be considered in MOBI format? I mean, like the trouble with images...
The other problem you will likely have is with CSS statements. Mobi format does not support CSS at all, nada. The conversion programs will attempt to convert some CSS into something that mobi will understand but it can be spotty and the results may not look like what you expected. KindleGen tends to be better at converting CSS than is MobiPocket Creator.

The ePub specific toc file will be used by KindleGen to create the chapter marks on the progress bar but not to create the Mobi specific TOC. It will need to be created separately. MobiPocket Creator can make this by identifying the rule used to create it such as all h1, h2 headers.
DaleDe is offline   Reply With Quote
Old 03-01-2012, 01:38 PM   #10
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 9,424
Karma: 43260000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
In keeping with the above mentioned CSS conversion issues:

If you're trying to maintain one unified document for ePub and MOBI, keep in mind that kindlegen's css conversion logic can't cope with more than one class being assigned to a single element. so...
Code:
<p class="first-class second-class">text here</p>
just won't work.

Something like:
Code:
<p class="first-class"><span class="second-class">text here</span></p>
will have a much better chance of being successfully converted to mobi (while still being valid for ePub). Or you could combine the attributes of the two classes into one if possible. Just don't plan on being able to "stack" CSS classes to achieve your desired effect (Note: the KF8 format has no such limitation).
DiapDealer is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with images - epub to mobi conversion LynnGHughes Kindle Formats 18 04-17-2012 10:56 AM
Calibre ePUB to mobi conversion help (with images) anamardoll Conversion 6 02-19-2012 11:53 PM
images lost converting epub to mobi fwiginton Calibre 0 01-21-2012 01:21 PM
epub to mobi error when including images HarrisS Conversion 1 02-08-2011 09:57 AM
help mobi to epub conversion: lost all images Sylver Calibre 10 01-13-2011 09:31 PM


All times are GMT -4. The time now is 04:08 PM.


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