9

I'm experimenting with Calibre. I have a Word document, with several JPEG images inserted, each of them 537px wide. I exported the document as html, zipped everything and re-opened in Calibre.

After conversion, in the Calibre reader the images are squashed horizontally. Is there anyway to have them scale proportionally?

Also, the cover - a PNG - does not scale proportionally (e.g. when the TOC is opened, it squashes horizontally too).

thanks

2
  • In to which format are you converting your document?
    – Sekhemty
    Mar 26, 2014 at 17:27
  • I'm saving as epub. Mar 26, 2014 at 19:15

2 Answers 2

1

This sounds like a problem with the CSS that Calibre is generating for the epub file. Without seeing the code, it's impossible to say for sure, but my guess is that it's got the width and height for images both set to 100%, which would distort the images in the way you're describing. The answer is to simply remove the height declaration, which will make the images full width of whatever height is appropriate given their aspect ratio.

I don't use Calire, so I can't tell you how to use that tool to do this, but if you're comfortable editing HTML and CSS, all you'll need to do is crack open the epub file (rename it from .epub to .zip, then unzip it), find the images being affected in the HTML, figure out which selectors the CSS is targeting them with, and go change the relevant CSS declarations.

4
  • the css gives the exact size of each image, e.g - .calibre21 { width:596px; height: 367px;}, but I don't think any image was 596px wide. (The word doc's in the office.) Mar 26, 2014 at 19:22
  • In that case, just remove the height. I would also suggest making the width 100% rather than a pixel width.
    – Tom
    Mar 26, 2014 at 19:23
  • OK will try that and let you know. Mar 26, 2014 at 19:25
  • great, glad it worked out!
    – Tom
    Mar 26, 2014 at 20:00
0

An alternative answer to Tom's proposition to modify CSS:

I didn't want to manually change the HTML/CSS files. I have an original LaTeX file, that I convert into HTML/CSS using htlatex my_file.tex and then I convert it into mobi using Calibre. My images were distorted too.

One solution to keep all the process automatic is to decrease the size of the original pictures, e.g., using convert my_pic.png -resize x500 my_pic.png. It works for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.