本文整理汇总了Python中Image.Image.generateFromPpt方法的典型用法代码示例。如果您正苦于以下问题:Python Image.generateFromPpt方法的具体用法?Python Image.generateFromPpt怎么用?Python Image.generateFromPpt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image.Image
的用法示例。
在下文中一共展示了Image.generateFromPpt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generateImageFromFile
# 需要导入模块: from Image import Image [as 别名]
# 或者: from Image.Image import generateFromPpt [as 别名]
def generateImageFromFile(file_path, output_dir):
'Generates an image file from each slide. Returns the paths to the images.'
presentation = PptxFile(file_path)
no_of_slides = len(presentation.getSlides())
presentation.destroy() #Delete extracted folder
image = Image()
pptx = os.path.abspath(file_path)
output_folder = os.path.abspath(output_dir)
image_paths = image.generateFromPpt(pptx, output_folder, no_of_slides)
return image_paths
示例2: generateImageFromData
# 需要导入模块: from Image import Image [as 别名]
# 或者: from Image.Image import generateFromPpt [as 别名]
def generateImageFromData(data, image_names):
'Generates an image file from each slide. Input is the binary data of the slide or deck'
'and a list of names. Renames the images and returns a list of paths.'
temp_folder = relative_path("Files/Temp")
bin = temp_folder + "/File.bin"
pptx = temp_folder + "/File.pptx"
if not (os.path.exists(temp_folder)):
os.makedirs(temp_folder)
open(bin,"wb").write(data)
shutil.move(bin, pptx)
presentation = PptxFile(pptx)
no_of_slides = len(presentation.getSlides())
presentation.destroy() #Delete extracted folder
image = Image()
pptx_dir = os.path.abspath(pptx)
temp_paths = image.generateFromPpt(pptx_dir, temp_folder, no_of_slides)
n = len(temp_paths)
if (len(image_names) != n):
for i in xrange (0, n):
os.remove(temp_paths[i])
raise Exception ("Amount of generated slides differs from lenght of input parameter")
for i in xrange (0, n):
shutil.move(temp_paths[i], image_names[i])
os.remove(pptx)
return image_names