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

Go Back   MobileRead Forums > E-Book Software > Calibre > Recipes

Notices

Reply
 
Thread Tools Search this Thread
Old 09-29-2014, 10:52 AM   #1
pbw
Member
pbw began at the beginning.
 
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?
pbw is offline   Reply With Quote
Old 09-29-2014, 10:54 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,202
Karma: 23446406
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.
kovidgoyal is offline   Reply With Quote
Advert
Old 09-29-2014, 08:33 PM   #3
pbw
Member
pbw began at the beginning.
 
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.
pbw is offline   Reply With Quote
Old 09-29-2014, 10:22 PM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,202
Karma: 23446406
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.
kovidgoyal is offline   Reply With Quote
Old 09-30-2014, 10:38 AM   #5
pbw
Member
pbw began at the beginning.
 
Posts: 21
Karma: 10
Join Date: Dec 2011
Device: Kindle
Quote:
Originally Posted by kovidgoyal View Post
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.
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.
pbw is offline   Reply With Quote
Advert
Old 09-30-2014, 11:18 AM   #6
pbw
Member
pbw began at the beginning.
 
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.
pbw is offline   Reply With Quote
Old 09-30-2014, 11:23 AM   #7
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,202
Karma: 23446406
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.
kovidgoyal is offline   Reply With Quote
Old 09-30-2014, 11:21 PM   #8
pbw
Member
pbw began at the beginning.
 
Posts: 21
Karma: 10
Join Date: Dec 2011
Device: Kindle
Quote:
Originally Posted by kovidgoyal View Post
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.


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.
pbw is offline   Reply With Quote
Old 09-30-2014, 11:36 PM   #9
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,202
Karma: 23446406
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.
kovidgoyal is offline   Reply With Quote
Old 10-01-2014, 09:15 PM   #10
pbw
Member
pbw began at the beginning.
 
Posts: 21
Karma: 10
Join Date: Dec 2011
Device: Kindle
Quote:
Originally Posted by kovidgoyal View Post
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.
In the generated EPUB, there are not dimensions on the image, only a class, "calibre8". So the viewer seems to be acting unilaterally when resizing only the width.
pbw is offline   Reply With Quote
Old 10-01-2014, 10:40 PM   #11
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,202
Karma: 23446406
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Look at the contents of that class
kovidgoyal is offline   Reply With Quote
Old 10-03-2014, 04:41 AM   #12
pbw
Member
pbw began at the beginning.
 
Posts: 21
Karma: 10
Join Date: Dec 2011
Device: Kindle
Quote:
Originally Posted by kovidgoyal View Post
Look at the contents of that class
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.
pbw is offline   Reply With Quote
Reply

Tags
image aspect ratio, image conversion, news recipe

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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


All times are GMT -4. The time now is 06:16 PM.


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