Contents | Start | End | Previous: Chapter 10: Troubleshooting Your Book | Next: Chapter 12: Working With Indexes


Chapter 11: Working With Pictures

In addition to text, Jutoh supports pictures (also referred to as ‘images’ within the Jutoh user interface). Jutoh has a variety of methods to convert and resize pictures; this chapter tells you all you need to know.

Inserting and editing pictures

To show pictures in your book, you can paste them into a page, or choose Format | Insert | Picture. Inserting the picture will show a browser that displays thumbnails of all the pictures in a folder.

The picture browser dialog

If the inserted or pasted image width is larger than the one specified in Resize images to max, in Import Preferences, the image will be resized before insertion into the project.

You can use these formats in Jutoh:

Note that by default, Jutoh will convert non-JPEG image files to JPEG – see Image export to ebooks below for more details. In the case of TIFF images, you need Jutoh to convert them to JPEG since Epub and Mobipocket do not support TIFF.

A pasted image will always be inserted as a PNG. If you want to insert an image as a particular type, such as JPEG, you can use Format | Insert | Picture to insert it as a file, instead.

An image always takes up a character position in the editor; if you have one image on its own in a paragraph you can apply paragraph formatting to make it left-aligned, right-aligned or centred. If you want text to wrap around it, you cannot show this in the editor. However, you can achieve floating images in your Epub book (not Mobipocket, unfortunately, since it doesn’t support wrapping around images) by setting properties for the image – right click over the image (or control-click on Mac) and select Properties. Now you can select float mode (left, right or none), padding for each side, and other properties. You won’t be able to see any change in the editor, but Jutoh will apply the changes to your Epub book.

The Image Properties dialog

If setting the float mode to left or right, text that should flow around it should be in the same paragraph as the image. Otherwise there will be extra paragraph spacing around the image.

Image size specified in the individual image properties (as distinct from the resizing done by Jutoh as described below) is respected by some viewers and not others. In particular, early Kindle devices will ignore the specified pixel width and height and will use the original resolution, scaled to fit if necessary, whereas newer versions of Kindle hardware and software take pixel and percentage size specifications into account. Most Epub viewers recognise pixel, cm and percentage size specification.

Note that separate image documents in your project (created via Document | Add Image Document or the toolbar new document command) are not included in your ebooks. These documents are purely to help you organize pictures that might or might not be pasted into the book at some point.

Special considerations for iBooks

A problem that many people find with images in iBooks Epub files is that iBooks ignores width and height specifications in images, and fits images to the page instead. This can be bad because you may wish to include high-resolution images which will look good on high-resolution devices such as retina-display iPads, while keeping the image to a particular size. The workaround for this is to use a parent div that takes the image’s size, and have the image expand to the size of the parent. From Jutoh 1.57, this optimization is applied when Optimize for iBooks is checked in your configuration. An image that is on its own in a paragraph (without any other content), and has its size dimensions specified in its properties, is generated using a div that takes the dimensions of the image, and dimensions are removed from the image itself.

So, to support a variety of device resolutions, it’s a good idea to specify high-resolution images and specifiy the desired size (just one of the dimensions will do). Currently this won’t work if you have multiple images or other content in a paragraph.

Inserting SVG pictures

The SVG format is used for scalable vector graphics, and in some cases can provide better quality than bitmaps. Not all ebook software and hardware support SVG but it's an increasingly popular format. Jutoh doesn't directly support insertion of SVG files into the editor, but there are two ways of getting SVG pictures into your ebooks.

In both cases, you should add media documents to your project, containing the SVG images. Now you have two options:

  1. Insert a reference to the media object with Format | Insert | Media Object. Choose the image you previously added as a media document. A placeholder icon is added, and you can click on it to change the properties.

  2. Insert a regular image (PNG, JPEG) that duplicates the look of the SVG image. In the image properties, type the name of the SVG image in the field SVG alternative, such as media/mypicture.svg. Now check the configuration property Use SVG images to write SVG images instead of bitmaps. You may need to specify the image width and height in image properties for the SVG to be displayed correctly.

With the second option, you can use configurations to control whether SVG or bitmap images are exported, so this allows you to maintain different configurations for creating ebooks with either SVGs or bitmap images for different sites or devices.

Importing pictures from DOCX, ODT and HTML

You can control some aspects of picture import when they are part of documents imported via the New Project wizard. In the Import Preferences pane in the Preferences dialog, or in the Import Options page in the New Project Wizard, you can choose whether to import images or not, and whether to resize them and to what size.

If you want to specify the image size later, you can clear the Respect specified image size option. This will force images to be imported either at the width you specify, or at the maximum resolution they have in the original file. Then you can specify the maximum image width and height in your configurations for later resizing (see Image export to ebooks below).

Some types of picture cannot be imported from ODT documents (in particular SVM, the StarView Metafile format). These pictures should be pasted or inserted by hand after import. Or, export an HTML file using OpenOffice or LibreOffice, to the same folder that contains the ODT and with the same root name as the original file. For example, thing.odt should be exported as thing.html. GIF files will be written to the folder, and Jutoh will use these images when importing from ODT.

Pictures pasted from the clipboard into a DOCX file are stored as Windows Metafiles. These can be imported by Jutoh on Windows, although picture size may be slightly different from the original. On Linux and Mac OS X, metafiles are ignored, so you have several options:

  1. perform the document import on a Windows machine and copy the .jutoh file afterwards to your Linux or Mac machine;

  2. in your original DOCX file, replace pasted images with images inserted from PNG or JPEG files and then perform the import; or

  3. paste or insert the missing images into your Jutoh project.

Image export to ebooks

By default, Jutoh will convert non-JPEG images to the more space-efficient JPEG format. You can switch this off via the Convert images to JPEG configuration setting. You can also choose the compression ratio when converting, using the Image quality configuration property – the higher the value, the better the quality. 80% is usually a good value.

You can also control the maximum image width and height, using the Maximum image width and Maximum image height properties. If one or both values are specified, Jutoh will resize each image on export if one or both of its dimensions exceed the specified maximum. In this way, you can easily create multiple books with images optimized for different screen sizes.

An additional option – Maximum image optimization width applies an optimization for images whose width is the same or smaller, by simply doubling the size before rescaling back down. This improves image quality at the expense of longer compile times, so you might like to have a configuration with this set to -1 for ‘preview compiles’ if you have a lot of images.

The above options determine the maximum image size at the time the image is written to the ebook. However, often you will not know in advance what size is best for the device that is being used. Kindle viewers will automatically scale images to fit, but for Epubs, you might like to check Limit images to viewer size this generates CSS that limits the image size to the maximum width or height of the current viewer. This will only work if you have one image on a line, since two images side-by-side will get a combined 200% of the viewer width or height. You can override the maximum width and height on a per-image basis by specifying these values in the image properties dialog. If your image is too big for the device display, it could break across two pages – this can cause the Epub to be rejected by iTunes, so make sure Limit images to viewer size is checked if your book contains large images.

If your PNG images contain alpha transparency, by default Jutoh will ‘flatten’ them, that is, remove the transparency and give the images a white background. You can suppress this by clearing the Flatten images configuration option. If you do not flatten images, they may end up as black boxes in your ebook. Note that GIF images cannot be flattened, unless converting to JPEG.

If you find your images look a little blurry (particularly if you’re using images for symbols or equations), switch conversion to JPEG off in your configuration(s), or use GIFs and set Convert images to JPEG to “All except GIF”. Or, you can leave JPEG conversion on, but for selected images such as symbols and diagrams, check the Preserve original format option in each image’s properties.

If you have multiple instances of the same image in your project, you can indicate to Jutoh which images should only be exported once by choosing a unique name for the Name field in the image properties dialog; the first image with a given name will be exported, and subsequent occurrences will use the same image. The name will also be used as the root of the image file name. Don’t use non-ASCII characters, such as Chinese characters, for file names or EpubCheck and/or Kindlegen will fail.

Exporting images to files

If you need to extract all images from your book, in their original format and size, you can use the File | Export | Images command. It will prompt you for a folder that will contain the files. If you need to get hold of the files that have been converted to JPEGs and resized as part of the book compilation process, then you can unzip the Epub file using an archive tool, renaming the extension to zip first if necessary.

Using media objects to insert images

Instead of inserting images directly, you can insert media documents and then add media objects that refer to them. For more on this, see Embedding media.

Summary

We’ve seen how to insert pictures and adjust the way they are saved in your compiled ebooks. Next, we look at further refinements for your books, namely getting Jutoh to help create various kinds of index section.


Contents | Start | End | Previous: Chapter 10: Troubleshooting Your Book | Next: Chapter 12: Working With Indexes