Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to activate and utilize the MORPH transision feature #942

Open
nnako opened this issue Feb 3, 2024 · 4 comments
Open

how to activate and utilize the MORPH transision feature #942

nnako opened this issue Feb 3, 2024 · 4 comments

Comments

@nnako
Copy link

nnako commented Feb 3, 2024

Hi,

I was wondering if it was currently possible to activate and use the morph feature for transitioning an image element between two slides (thus changing its location, orientation, zoom, ...). If there is the possibility to configure morphing using python-pptx, how could it be done? And if not yet, where whould I start digging into the PPTX file and the python-pptx code base to work out a solution?

Thanks.

@nnako
Copy link
Author

nnako commented Mar 23, 2024

meanwhile, I tested some examples and found out that the only difference between a PPTX file without and with morphing would basically be the following.

Assuming, on slide 1 there was a picture and on slide 2 there was the same picture (same name as seen in the selection pane) at a maybe different position and a different zoom level, ... . Then, the difference between the two files

ppt / slides / slide1.xml

and

ppt / slides / slide2.xml

would be an additional constant xml text at the bottom of slide2.xml (compared to slide1.xml) which looks like this:

<mc:AlternateContent xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
	<mc:Choice xmlns:p159="http://schemas.microsoft.com/office/powerpoint/2015/09/main" Requires="p159">
		<p:transition spd="slow" xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" p14:dur="2000">
			<p159:morph option="byObject"/>
		</p:transition>
	</mc:Choice>
	<mc:Fallback>
		<p:transition spd="slow">
			<p:fade/>
		</p:transition>
	</mc:Fallback>
</mc:AlternateContent>

So, a starting point might be to localize where in the code base it would be best to cause this xml text block to be written into the appropriate file. This would cause a morph effect whenever the transition goes from slide 1 to slide 2 in presentation mode. There is one oddity, though. As soon as the slides contain un-filled placeholders, the morph will not work. So, the code would have to deal with this as well.

Any hints, where to find a suitable place within the code base to start a 1st implementation?

@MartinPacker
Copy link

MartinPacker commented Mar 24, 2024

In md2pptx I attach an AlternateContent element under the slide element.

Might help.

@nnako
Copy link
Author

nnako commented Mar 25, 2024

Hi @MartinPacker , thanks. Wouldn't the functions you already developed within md2pptx not be perfectly suitable to be integrated in the python-pptx code base? At least the ones which make activating shadows, morph, and other effects much easier to be realized?

@MartinPacker
Copy link

Possibly. I'm not authorised by my employer (IBM) yet to contribute to the python-pptx base. Given the (understandably) high barrier to contributing to python-pptx I probably won't pursue that.

Also the functions probably aren't watertight.

So, feel free to borrow them. But I dont think I'm going to be the one to contribute them to python-pptx.

I'd be interested, though, in whether they need enhancing - to add more effects. I'd then work on those and add them to md2pptx. Or someone else can contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants