我想在PPT占位符中放置图片,并查看以下两个链接:
从类似的问题开始,我已经应用了解决方案,但它仍在ppt中显示裁剪的图像。
我的相同代码:
Not Overlapping
Overlapping
Not Overlapping
Overlapping
Not Overlapping
Overlapping
Not Overlapping
Overlapping
Not Overlapping
Overlapping
Not Overlapping
Overlapping
对于prs = Presentation(path)
title_slide_layout = prs.slide_layouts[4] ## Changed the content to picture as I need two pictures in one slide
pic_placeholder = slide.placeholders[15] ## The two picture placeholders
pic_placeholder1 = slide.placeholders[16]
print(pic_placeholder.left.inches, pic_placeholder.top.inches, pic_placeholder.width.inches, pic_placeholder.height.inches)
## 0.5 2.4461811023622047 4.4184033245844265 4.253472222222222
"""Below solution from the question posted above """
pic_placeholder.left = Inches(0.1)
pic_placeholder.width = Inches(3)
pic_placeholder.height = Inches(3)
##Similarly I need to do for 2nd picture also, but it is not working for this picture also
prs.save(path)
链接,我无法理解最终的解决方案是什么,如何实现。
问题陈述 :(您想要实现什么?
想要在一张幻灯片中并排显示两个图像,它们应该适合占位符并保留长宽比
您尝试了什么?
上面的代码是我尝试过的!!
它在哪些特定方面不起作用?
实施该解决方案时,我仍然从一侧获取裁剪的图像。
我想要的是一张幻灯片上的两个不同的图像,而且都没有被裁剪!!
答案 0 :(得分:0)
图片占位符没有“缩小至适合”选项。无论您要对插入的图片进行其他任何调整,您都需要自己做。
您尚未显示用于插入图片的代码,因此我无法为您提供具体的代码。但是,请注意,从picture_placeholder.insert_picture()
返回的对象不是picture_placeholder
对象本身。该对象将在该过程中被删除(就像在PowerPoint中在其中执行此操作时一样),并被图片对象替换。因此,您对现在孤立的占位符元素所做的任何调整都将无效。您需要更多类似这样的东西:
inserted_picture = picture_placeholder.insert_picture(...)
inserted_picture.left = ...
inserted_picture.width = ...