Skip to content

[Epic] Pictures, SVG & Picture Effects — replace_image, picture-fill, recolor, transparency #15

@MHoroszowski

Description

@MHoroszowski

Problem

The picture API is half-built. The most-asked feature is Picture.replace_image() (scanny/python-pptx#116, 23 comments) — replace a picture's blob in-place while preserving its size, position, crop, and shape effects. SVG embedding is unsupported despite being native PowerPoint since 2016 (scanny/python-pptx#1112, scanny/python-pptx#1115) — two independent forks have implemented it, signalling real demand. Picture-fill on shapes (scanny/python-pptx#234, #419) round-trips on read but has no setter on FillFormat. Recolor, transparency, and artistic effects (blur, paint, etc.) are entirely absent.

Sub-features

  • Picture.replace_image(image_file) — swap the blob, keep the position/size/crop/effects
  • FillFormat.picture(image_file, ...) setter mirroring solid() / gradient() / pattern() for shape fills
  • Native SVG embedding via <asvg:svgBlip> extension (auto-fallback PNG)
  • Picture transparency: Picture.transparency = 0.5 emitting <a:alphaModFix amt=>
  • Picture recolor: Picture.recolor(luminance=, brightness=, contrast=, color=) mapping to <a:lum>, <a:duotone>
  • Picture artistic effects (read+round-trip preservation; write API in Phase B): <a14:imgEffectLst> for blur, paint strokes, etc.
  • MPO-encoded JPEG handling (iPhone HDR), TIFF support
  • PicturePlaceholder fit-to-placeholder semantics (closes #176)

Prior art

Acceptance criteria

  • Picture.replace_image() preserves size/position/crop/effects exactly (test by image-blob diff + XPath assertions).
  • An SVG inserted via add_picture("logo.svg") opens as native SVG in PowerPoint Mac/Win (verify with file → save-as XML and check for <asvg:svgBlip>).
  • FillFormat.picture("texture.jpg") sets a shape fill to a tiled or stretched picture.
  • 25+ behave scenarios.
  • File-size regression test: replacing a 5MB image with a 100KB image actually shrinks the package.

Effort: M

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:picturesFeature area: picturesepicMulti-feature roadmap epicprior-art:forkActive community fork has shipped thisprior-art:upstream-prOpen PR on scanny/python-pptx is candidate cherry-pickpriority:P1Important but not urgent

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions