a:pic (Picture)
Represents a picture or image element in DrawingML with positioning, sizing, and visual effects.
Description
a:pic is the DrawingML picture element that represents an image or picture object. It is defined in ECMA-376 Part 1 §20.1.2.6.3.
Pictures embed images within Office documents through:
- A blip fill reference pointing to image data (PNG, JPEG, etc.)
- Shape properties defining the picture frame (position, size, effects)
- Non-visual properties for naming and metadata
- Support for visual effects (shadows, reflections, rotations)
Pictures are used for:
- Embedded images in presentations and documents
- Photo galleries and image collections
- Branded graphics and logos
- Illustrations and diagrams
- Background images for shapes
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
| (none) | - | - | All properties defined through child elements. |
Examples
Simple Picture with Sizing
<p:pic xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<p:nvPicPr>
<p:cNvPr id="1" name="Picture 1"/>
<p:cNvPicPr/>
<p:nvPr/>
</p:nvPicPr>
<p:blipFill>
<a:blip r:embed="rId2" cstate="print"/>
<a:stretch>
<a:fillRect/>
</a:stretch>
</p:blipFill>
<p:spPr>
<a:xfrm>
<a:off x="1000000" y="1000000"/>
<a:ext cx="3000000" cy="2250000"/>
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst/>
</a:prstGeom>
</p:spPr>
</p:pic>
using DocumentFormat.OpenXml.Presentation;
using DocumentFormat.OpenXml.Drawing;
using DocumentFormat.OpenXml;
var pic = new Picture();
// Non-visual properties
var nvPicPr = new NonVisualPictureProperties();
nvPicPr.Append(new NonVisualDrawingProperties { Id = 1, Name = "Picture 1" });
nvPicPr.Append(new NonVisualPictureDrawingProperties());
nvPicPr.Append(new PictureNonVisualProperties());
pic.Append(nvPicPr);
// Blip fill (image reference)
var blipFill = new BlipFillProperties();
var blip = new Blip { Embed = "rId2", CompressionState = BlipCompressionValues.Print };
blipFill.Append(blip);
var stretch = new Stretch();
stretch.Append(new FillRectangle());
blipFill.Append(stretch);
pic.Append(blipFill);
// Shape properties (frame sizing)
var spPr = new ShapeProperties();
var xfrm = new Transform2D();
xfrm.Append(new Offset { X = 1000000, Y = 1000000 });
xfrm.Append(new Extents { Cx = 3000000, Cy = 2250000 });
spPr.Append(xfrm);
var prstGeom = new PresetGeometry { Preset = ShapeTypeValues.Rectangle };
prstGeom.Append(new AdjustmentValueList());
spPr.Append(prstGeom);
pic.Append(spPr);
Picture with Effects (Shadow + Border)
<p:pic xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<p:nvPicPr>
<p:cNvPr id="2" name="Picture 2"/>
<p:cNvPicPr/>
<p:nvPr/>
</p:nvPicPr>
<p:blipFill>
<a:blip r:embed="rId3"/>
<a:stretch>
<a:fillRect/>
</a:stretch>
</p:blipFill>
<p:spPr>
<a:xfrm>
<a:off x="2000000" y="1500000"/>
<a:ext cx="2500000" cy="2000000"/>
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst/>
</a:prstGeom>
<a:ln w="25400">
<a:solidFill>
<a:srgbClr val="000000"/>
</a:solidFill>
</a:ln>
<a:effectLst>
<a:outerShdw blurRad="76200" dist="50800" dir="2700000">
<a:srgbClr val="000000">
<a:alpha val="50000"/>
</a:srgbClr>
</a:outerShdw>
</a:effectLst>
</p:spPr>
</p:pic>
var pic = new Picture();
var nvPicPr = new NonVisualPictureProperties();
nvPicPr.Append(new NonVisualDrawingProperties { Id = 2, Name = "Picture 2" });
nvPicPr.Append(new NonVisualPictureDrawingProperties());
nvPicPr.Append(new PictureNonVisualProperties());
pic.Append(nvPicPr);
var blipFill = new BlipFillProperties();
blipFill.Append(new Blip { Embed = "rId3" });
blipFill.Append(new Stretch { FillRectangle = new FillRectangle() });
pic.Append(blipFill);
var spPr = new ShapeProperties();
var xfrm = new Transform2D();
xfrm.Append(new Offset { X = 2000000, Y = 1500000 });
xfrm.Append(new Extents { Cx = 2500000, Cy = 2000000 });
spPr.Append(xfrm);
var prstGeom = new PresetGeometry { Preset = ShapeTypeValues.Rectangle };
prstGeom.Append(new AdjustmentValueList());
spPr.Append(prstGeom);
var ln = new Outline { Width = 25400 };
var fill = new SolidFill();
fill.Append(new RgbColorModelHex { Val = "000000" });
ln.Append(fill);
spPr.Append(ln);
var effectLst = new EffectList();
var outerShdw = new OuterShadow { BlurRadius = 76200, Distance = 50800, Direction = 2700000 };
var color = new RgbColorModelHex { Val = "000000" };
color.Append(new Alpha { Val = 50000 });
outerShdw.Append(color);
effectLst.Append(outerShdw);
spPr.Append(effectLst);
pic.Append(spPr);
Notes
- Picture element references image data via r:embed relationship ID
- Blip fill stretch maintains aspect ratio by default
- Picture frame properties control border, shadow, and visual effects
- Common image formats: PNG, JPEG, BMP, GIF, TIFF
- Compression state: print (print-optimized) or screen (screen-optimized)
- Pictures can be rotated, flipped, and cropped via transform properties
- Effects (shadows, glows) apply to the picture frame, not the image itself
- Width and height in EMUs (914400 = 1 inch)