python-pptx icon indicating copy to clipboard operation
python-pptx copied to clipboard

Feature request: Extracting transparency (alpha), Freeform shapes, and images in Picture fill

Open YeolJ00 opened this issue 1 year ago • 3 comments

I've found that some elements that the current library provides functionalities to draw are not extractable from the .pptx file. I would enjoy some symmetry in the functionalities, as I am trying to check if I can reconstruct pptx slides after extracting/abstracting their information. It seems to be that you are aware of these missing features but filing a feature request anyways.

  1. The first one is extracting transparency from shapes. Probably should be done in shape.fill perhaps? I believe that transparency applies to all fill types.

  2. Another one is extracting the path (verticies) from freeform shapes. This seems more difficult than the previous one, but it would be nice to have access to at least some raw form of the path.

  3. The last request is extracting byte images in the Picture fill type. This somewhat relates to the transparency issue as Picture fill in shapes is usually used to make transparent images.

I hope I didn't smash unrelated requests in a single issue. But I found that these share similarities in terms of missing symmetry on the extraction side.

YeolJ00 avatar Oct 16 '24 00:10 YeolJ00

It's probably not as "shrink wrapped " as you'd like but I expect the information is in the XML.

MartinPacker avatar Oct 16 '24 05:10 MartinPacker

@MartinPacker You are 100% right. The XML should provide what I need. That is also the reason why I made this a feature request. It would be nice if the library supports more of get_attr-style functions, so that one wouldn't have to dabble between parsing XML themselves and using the library.

YeolJ00 avatar Oct 16 '24 05:10 YeolJ00

I implemented extract images from MSO_FILL_TYPE.PICTURE: It should work like this:

image = shape.part.get_image(shape.fill._fill.rId)

link: https://github.com/Force1ess/python-pptx/commit/78b54c9b161a5766032d2d15f0fa7a0fc2308020

Force1ess avatar Mar 14 '25 14:03 Force1ess