Product SiteDocumentation Site

4.2. Adding images

Store images in the images subdirectory in the directory that holds your XML files. Use ./images/image-name to insert images into a book. The following is an example that inserts the testimage.png image:
<mediaobject>
<imageobject>
	<imagedata fileref="./images/testimage.png" />
</imageobject>
<textobject><phrase>alternate text goes here</phrase></textobject>
</mediaobject>

Ensure that you supply a <textobject> so that your content remains accessible to people with visual impairments. In certain jurisdictions, you might have a legal responsibility to provide this accessibility — for example, if you or your organization must comply with Section 508 of the United States Rehabilitation Act of 1973.[1]
If your book contains images that need to be localized — for example, screenshots of a user interface in a language other than the original language of your book — place these images in the images subdirectories for each language directory. Make sure that the image file in the translated language has the same name as the image file in the original language. When you build the book in the translated language, Publican uses the file from the images/ subdirectory of the translated language instead of the file from the images/ subdirectory of the original language.
Large images present poorly in HTML because they often go beyond the right margin of the text. Similarly, images wider than 444 pixels often go beyond the right margin of PDF pages and are cropped so that only the left side of the image is visible. Therefore, by default, Publican creates HTML and PDF output that instructs web browsers and PDF viewers to scale down any images larger than 444 pixels wide. Note, however, that images lose quality significantly when scaled in this way. For best results, scale or crop your images in image editing software so that they are no more than 444 pixels wide before you place them in a document.
To override Publican limiting the image width to 444 px, specify an image width in the <imagedata> tag. For example, to set an image width to 670 pixels:
<imagedata fileref=".images/image.png" width="670px">
If you override the default maximum image width, take care to review your output to ensure that quality standards are met.

Image file locations

Publican only uses images in the images subdirectory of your XML directory and corresponding images in the images subdirectories of your translated languages. Images stored in other directories directories do not work.

PNG files in PDF documents

Publican depends on an external application, FOP, to render documents as PDF files. At present, some versions of FOP contain a bug that alters the colors in certain images in PNG format. Specifically, 32-bit PNG images are rendered correctly, while 24-bit PNG images are not.
If you notice that Publican produces a PDF file that contains images with incorrect colors, convert the original PNG files to 32-bit PNG format by adding an alpha channel to the image and rebuild the book. If your chosen image manipulation software does not include an option specifically labeled Add alpha channel, the option might be labeled Add transparency instead.