09-29-2014, 10:52 AM | #1 |
Member
Posts: 21
Karma: 10
Join Date: Dec 2011
Device: Kindle
|
Image size lost
I'm tinkering with The Australian's recipe to clean things up a little, and I seem to be getting the hang of it. However, images that are captured lose their specified dimensions in the conversion to EPUB. I suppose this is actually a conversion problem. I have no idea how to go about preserving the image attributes, or at least the image aspect ratio, through the recipe.
Can anyone point me in the right direction? |
09-29-2014, 10:54 AM | #2 |
creator of calibre
Posts: 44,415
Karma: 23977332
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Conversion does not change image aspect ratios. Most likely the source has some markup that sets the image width or height using a percentage size like 100% so that the image gets distorted when viewed.
|
09-29-2014, 08:33 PM | #3 |
Member
Posts: 21
Karma: 10
Join Date: Dec 2011
Device: Kindle
|
Thanks Kovid. The source has height and width specified on the images as
<div class="image-frame image-650w366h"> <img src="http://resources1.news.com.au/images/2014/09/28/1227073/318401-2e1144a8-46d4-11e4-9a7c-3b6b503b5f0c.jpg" alt="Work with Syria to beat ISIS: Iraq" width="650" height="366" /> </div> So, on the webpage, they're absolute values. Here's the generated epub from a different article in The Australian. <div class="calibre6"> <img src="images/img1_u55.jpg" alt="Spain in crisis over Catalan referendum " class="calibre8"/> </div> Admittedly, I cannot follow the complete chain from RSS feed to EPUB, so I don't know exactly where in the process the size information gets lost. |
09-29-2014, 10:22 PM | #4 |
creator of calibre
Posts: 44,415
Karma: 23977332
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Do this if you want to follow the chain
ebook-convert file.recipe .epub --debug-pipeline p Then the HTML from the various steps of the conversion will be in the p sub-directory. |
09-30-2014, 10:38 AM | #5 |
Member
Posts: 21
Karma: 10
Join Date: Dec 2011
Device: Kindle
|
Thanks for that. It turns out that the EPUB, as you said, contains the correct images, but that the epub viewer scales them without preserving the aspect ratio. iBooks scales the images correctly on the fly, but Azardi, and otherwise excellent EPUB 2 and 3 viewer, stuffs up the placement of the images, which throws out the pagination.
|
09-30-2014, 11:18 AM | #6 |
Member
Posts: 21
Karma: 10
Join Date: Dec 2011
Device: Kindle
|
If I widen the page until the image fits, everything looks OK in the calibre viewer, as well.
I'm not sure what effect, if any, the settings compress_news_images = False compress_news_images_auto_size = 16 compress_news_images_max_size = None scale_news_images_to_device = True scale_news_images = None might have on this. |
09-30-2014, 11:23 AM | #7 |
creator of calibre
Posts: 44,415
Karma: 23977332
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
When the page viewing the image is too narrow, the images are auto-scaled by most viewers, I doubt that the auto-scaling preserves aspect ratio. I know in the calibre viewer it does not (it's implemented simply by setting max-width as opposed to using javascript, which is somewhat slower)
All those options simply control image file size and are irrelevant to aspect ratios. |
09-30-2014, 11:21 PM | #8 | |
Member
Posts: 21
Karma: 10
Join Date: Dec 2011
Device: Kindle
|
Quote:
Would it work to set max-height to a ratio-preserving value? Or is max-height a second-class citizen in the viewers? Incidentally, iBooks.app does seem to scale in both dimensions. Obviously, the app environment gives them a lot more flexibility. Even so, iBooks has very restricted MathML support. |
|
09-30-2014, 11:36 PM | #9 |
creator of calibre
Posts: 44,415
Karma: 23977332
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
A max-anything is only an upper limit. The viewer is free to resize the other dimension however it likes. Now as long as you dont set the width or height explicitly on the image, most viewers will resize them preserving aspect ratio. If you do set the width or height explicitly, then aspect ratio will be lost. So in your html, simply remove the explicit width/height setting and you will be fine.
|
10-01-2014, 09:15 PM | #10 | |
Member
Posts: 21
Karma: 10
Join Date: Dec 2011
Device: Kindle
|
Quote:
|
|
10-01-2014, 10:40 PM | #11 |
creator of calibre
Posts: 44,415
Karma: 23977332
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Look at the contents of that class
|
10-03-2014, 04:41 AM | #12 |
Member
Posts: 21
Karma: 10
Join Date: Dec 2011
Device: Kindle
|
The class included the width and height parameters from the original html.
By changing the css as follows .calibre8 { width: 100%; height: auto; /*height: 366px; width: 650px*/ } in the couple of image-related classes, I was able to to get the calibre viewer to present the images with aspect ratio intact. This change also seemed to be acceptable to iBooks and to Readium in the Chrome brewer, although I have not tested the unchanged EPUB in Readium. Azardi remains a problem, but I am talking to InfogridPacific separately about this issue. |
Tags |
image aspect ratio, image conversion, news recipe |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Cover Image Size | taguntumi | Marvin | 6 | 12-17-2013 04:59 AM |
Best image size for cover? | Alda | Sigil | 5 | 03-21-2013 05:46 AM |
Best image size for cover? | Alda | ePub | 1 | 03-20-2013 02:08 PM |
Image size issues | x2far | Sigil | 3 | 02-10-2012 04:40 AM |
Image Size | benjaminsolah | ePub | 13 | 09-24-2010 11:47 PM |