Place an image in a frame
Place a picture in IDML — nest an Image in a Rectangle, give it its own ItemTransform and GraphicBounds, and link the file with Link/LinkResourceURI.
An image in IDML is an <Image> nested inside a frame — usually a Rectangle — with its own transform and a link to the file.
In short There is no dedicated image-frame element. A graphic frame is a
Rectangle (or Oval, or Polygon) with an <Image> child, and InDesign marks such a
frame ContentType="GraphicType". The image carries its own ItemTransform, which maps
the picture's pixels into the frame, a GraphicBounds giving the picture's pixel box, and
a <Link> whose LinkResourceURI names the file. Download the sample.
The recipe
- Draw the frame. Add a
Rectangleto the spread with anItemTransformthat places it (in the example,1 0 0 1 150 200: 150 pt across, 200 pt down) and aPathGeometrytracing its outline. Mark itContentType="GraphicType", as InDesign does for every frame that holds a picture. - Nest an
<Image>inside it. TheImagechild is what holds the picture; the frame clips it. - Give the image its own
ItemTransform. It maps the picture's pixel space into the frame's space. The example uses0.5 0 0 0.5 0 0, a half-scale; the frame's transform then carries the result onto the spread. - Declare the picture's box. In the image's
<Properties>,<GraphicBounds>gives the picture's extent in its own pixel space,Left/Top/Right/Bottom— here0 0 600 400, a 600 × 400 pixel picture. - Link the file. Add a
<Link>whoseLinkResourceURInames it. InDesign writes an absolutefile:URI with one slash after the scheme and reserved characters percent-encoded, such asfile:/Users/me/Links/photo.jpgorfile:C:/Projects/Links/CODE%201.jpg.
A Rectangle holding an <Image> with its own half-scale ItemTransform, a
GraphicBounds pixel box, and a <Link> naming the file.
| Attribute · Link | Values | Paged | paged.set |
|---|---|---|---|
| LinkResourceURI | ref | read · written | imageUri |
| AssetID | builtin | not read | |
| AssetURL | builtin | not read | |
| CanEmbed | true | written | |
| CanPackage | true | written | |
| CanUnembed | true | written |
Things to get right
- The
Imageholds the picture;ContentTypelabels the frame. In InDesign's packages, every frame with anImage,PDF,EPSorImportedPagechild carriesContentType="GraphicType", and an empty frame meant for a picture does too. The sample's frame leaves the attribute out, which a reader keyed on the child does not notice. - Two transforms compose. The image's
ItemTransformplaces the picture inside the frame; the frame's places the frame on the spread. Move the whole thing with the frame's transform; crop or scale the picture with the image's. GraphicBoundsis the pixel box. Write0 0 width heightin pixels and let the image'sItemTransformdo the scaling. A frame-sizedGraphicBoundscombined with an explicit transform puts the picture in the wrong place in InDesign.- Use an absolute link. InDesign 20.0.1 resolves a relative
LinkResourceURIto nothing: the frame opens empty. The sample'sfile:Links/photo.jpgis relative and is reported as missing; with the picture missing, InDesign keeps the frame, its geometry and its crop, and shows a missing-link placeholder. - A picture can be embedded instead. An
<Image>can carry its pixels in a<Contents>child rather than linking them; see placed images.
In Paged: placed images are read from the nested
Image, positioned through the two transforms, and drawn from bytes the host supplies for the link; a link with no bytes is drawn as InDesign's missing-image placeholder.GraphicBoundsandContentTypeare carried but not used. Supported · verified
Frequently asked questions
What makes a frame an image frame?
The nested <Image> (or PDF, EPS, ImportedPage) child holds the picture. InDesign also
marks the frame ContentType="GraphicType", including an empty frame meant for a picture.
Why does an image have two transforms?
The image's ItemTransform maps its pixels into the frame (the example uses a half-scale),
and the frame's ItemTransform places the frame on the spread. Edit the frame's to move the
whole thing, the image's to crop or scale the picture inside it.
Which form of LinkResourceURI does InDesign resolve?
An absolute file: URI, written with one slash after the scheme and percent-encoded
reserved characters, such as file:/Users/me/Links/photo.jpg. A relative URI resolves to
nothing in InDesign 20.0.1.
Can the picture be embedded instead of linked?
Yes, as a <Contents> payload inside the <Image>. The
placed images reference covers it.
Apply a gradient fill
Define a Gradient swatch with GradientStops, point a shape's FillColor at it, and orient it with GradientFillAngle, GradientFillStart and GradientFillLength.
Element reference
Every IDML element found in 305 real documents: where it lives in the package, its attributes and values, and what Paged reads and writes.