scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.35k stars 510 forks source link

Advice on programming replace embededd image with a link #806

Open TerryHewitt opened 2 years ago

TerryHewitt commented 2 years ago

I want to replace an embedded image with a link. I can find the embedded image. I can generate a new rId: relationships = self.slide._part.rels reltype = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image' newrId = relationships._add_relationship(reltype, newfilename, True) let's say it generates 'rId3'

It seems there are two ways to the next bit: A) edit the xml of a pptx.shapes.picture object to change: to or B) delete the old image and insert a 'linked image'

I know how to change the size and position to adjust for different aspect ratios.

I'm at a loss about how to do the detail of either A) or B). Could someone provide some code snippets or guidance please?

Best wishes Terry