Paper Office
paper-pptxAPI referenceoxml.shapes.picture

CT_Picture

paper-pptx 0.2.0 API reference

p:pic element.

Represents a picture shape (an image placement on a slide).

Attributes

blipFill

attributeblipFill
= OneAndOnlyOne('p:blipFill')

blip_rId

attributeblip_rIdstr | None

Value of p:blipFill/a:blip/@r:embed.

Returns None if not present.

cx

attributecxLength

cy

attributecyLength

flipH

attributeflipH

flipV

attributeflipV

has_ph_elm

attributehas_ph_elm

True if this shape element has a p:ph descendant, indicating it is a placeholder shape. False otherwise.

ln

attributeln

<a:ln> grand-child element or None if not present

nvPicPr

attributenvPicPr
= OneAndOnlyOne('p:nvPicPr')

ph

attributephCT_Placeholder | None

The p:ph descendant element if there is one, None otherwise.

ph_idx

attributeph_idxint

Integer value of placeholder idx attribute.

Raises ValueError if shape is not a placeholder.

ph_orient

attributeph_orientstr

Placeholder orientation, e.g. 'vert'.

Raises ValueError if shape is not a placeholder.

ph_sz

attributeph_szstr

Placeholder size, e.g. ST_PlaceholderSize.HALF.

Raises ValueError if shape is not a placeholder.

ph_type

attributeph_type

Placeholder type, e.g. ST_PlaceholderType.TITLE ('title').

Raises ValueError if shape is not a placeholder.

rot

attributerotfloat

Float representing degrees this shape is rotated clockwise.

shape_id

attributeshape_id

Integer id of this shape

shape_name

attributeshape_name

Name of this shape

spPr

attributespPrCT_ShapeProperties
= OneAndOnlyOne('p:spPr')

srcRect_b

attributesrcRect_b

Value of p:blipFill/a:srcRect/@b or 0.0 if not present.

srcRect_l

attributesrcRect_l

Value of p:blipFill/a:srcRect/@l or 0.0 if not present.

srcRect_r

attributesrcRect_r

Value of p:blipFill/a:srcRect/@r or 0.0 if not present.

srcRect_t

attributesrcRect_t

Value of p:blipFill/a:srcRect/@t or 0.0 if not present.

txBody

attributetxBody

Child p:txBody element, None if not present.

x

attributexLength

xfrm

attributexfrm

The a:xfrm grandchild element or None if not found.

This version works for p:sp, p:cxnSp, and p:pic elements, others will need to override.

xml

attributexmlstr

XML string for this element, suitable for testing purposes.

Pretty printed for readability and without an XML declaration at the top.

y

attributeyLength

Functions

crop_to_fit

funccrop_to_fit(image_size, view_size)

Set cropping values in p:blipFill/a:srcRect such that an image of image_size will stretch to exactly fit view_size when its aspect ratio is preserved.

paramimage_size
paramview_size

first_child_found_in

funcfirst_child_found_in(*tagnames: str) -> _Element | None

First child with tag in tagnames, or None if not found.

paramtagnamesstr
= ()

Returns

lxml.etree._Element | None

get_or_add_ln

funcget_or_add_ln()

Return the <a:ln> grandchild element, newly added if not present.

get_or_add_xfrm

funcget_or_add_xfrm()

Return the a:xfrm grandchild element, newly-added if not present.

This version works for p:sp, p:cxnSp, and p:pic elements, others will need to override.

insert_element_before

funcinsert_element_before(elm: ElementBase, *tagnames: str)
paramelmElementBase
paramtagnamesstr
= ()

new_ph_pic

funcnew_ph_pic(id_, name, desc, rId)

Return a new p:pic placeholder element populated with the supplied parameters.

paramid_
paramname
paramdesc
paramrId

new_pic

funcnew_pic(shape_id, name, desc, rId, x, y, cx, cy)

Return new <p:pic> element tree configured with supplied parameters.

paramshape_id
paramname
paramdesc
paramrId
paramx
paramy
paramcx
paramcy

new_video_pic

funcnew_video_pic(shape_id: int, shape_name: str, video_rId: str, media_rId: str, poster_frame_rId: str, x: Length, y: Length, cx: Length, cy: Length) -> CT_Picture

Return a new p:pic populated with the specified video.

paramshape_idint
paramshape_namestr
paramvideo_rIdstr
parammedia_rIdstr
paramposter_frame_rIdstr
paramxLength
paramyLength
paramcxLength
paramcyLength

Returns

pptx.oxml.shapes.picture.CT_Picture

remove_all

funcremove_all(*tagnames: str) -> None

Remove child elements with tagname (e.g. "a:p") in tagnames.

paramtagnamesstr
= ()

Returns

None

xpath

funcxpath(xpath_str: str) -> Any

Override of lxml _Element.xpath() method.

Provides standard Open XML namespace mapping (nsmap) in centralized location.

paramxpath_strstr

Returns

typing.Any

On this page