Skip to main content

13.12.8 Images in ODT export

Embedding images​

The ODT export back-end processes image links in Org files that do not have descriptions, such as these links β€˜[[file:img.jpg]]’ or β€˜[[./img.jpg]]’, as direct image insertions in the final output. Either of these examples works:

[[file:img.png]]
[[./img.png]]

Embedding clickable images​

For clickable images, provide a link whose description is another link to an image file. For example, to embed an image β€˜org-mode-unicorn.png’ which when clicked jumps to https://orgmode.org website, do the following

[[https://orgmode.org][./org-mode-unicorn.png]]

Sizing and scaling of embedded images​

Control the size and scale of the embedded images with the β€˜ATTR_ODT’ attribute.

The ODT export back-end starts with establishing the size of the image in the final document. The dimensions of this size are measured in centimeters. The back-end then queries the image file for its dimensions measured in pixels. For this measurement, the back-end relies on ImageMagick’s identify program or Emacs create-image and image-size API. ImageMagick is the preferred choice for large file sizes or frequent batch operations. The back-end then converts the pixel dimensions using org-odt-pixels-per-inch into the familiar 72 dpi or 96 dpi. The default value for this is in display-pixels-per-inch, which can be tweaked for better results based on the capabilities of the output device. Here are some common image scaling operations:

Explicitly size the image​

To embed β€˜img.png’ as a 10 cm x 10 cm image, do the following:

#+ATTR_ODT: :width 10 :height 10
[[./img.png]]

Scale the image​

To embed β€˜img.png’ at half its size, do the following:

#+ATTR_ODT: :scale 0.5
[[./img.png]]

Scale the image to a specific width​

To embed β€˜img.png’ with a width of 10 cm while retaining the original height:width ratio, do the following:

#+ATTR_ODT: :width 10
[[./img.png]]

Scale the image to a specific height​

To embed β€˜img.png’ with a height of 10 cm while retaining the original height:width ratio, do the following:

#+ATTR_ODT: :height 10
[[./img.png]]

Anchoring of images​

The ODT export back-end can anchor images to β€˜as-char’, β€˜paragraph’, or β€˜page’. Set the preferred anchor using the β€˜:anchor’ property of the β€˜ATTR_ODT’ line.

To create an image that is anchored to a page:

#+ATTR_ODT: :anchor page
[[./img.png]]