当前位置: 首页 > news >正文

安阳网站设计哪家专业企业营销网站建立

安阳网站设计哪家专业,企业营销网站建立,电子商务网站建设与管理实训心得,创意平面设计公司简介语言#xff1a;python 3 用法#xff1a;点击运行后#xff0c;弹出窗口#xff0c;选择文件夹#xff0c;程序运行会将文件夹内的所有PPT文件全部转换成PPT长图#xff0c;图片名称与PPT文件名称相同#xff0c;保存位置相同。 如运行中报错#xff0c;需要自行根据…语言python 3 用法点击运行后弹出窗口选择文件夹程序运行会将文件夹内的所有PPT文件全部转换成PPT长图图片名称与PPT文件名称相同保存位置相同。 如运行中报错需要自行根据报错内容按照缺失的库 共分享两种代码可以尝试运行。 代码1需安装库 #安装库 pip install pyautogui #安装库 pip install  pillow import os import comtypes.client from tkinter import Tk, filedialog from PIL import Imagedef ppt_to_images(ppt_file):try:# 导入comtypes.client模块并创建PowerPoint应用程序对象powerpoint comtypes.client.CreateObject(Powerpoint.Application)# 设置PowerPoint应用程序为可见状态便于观察操作过程可选,修改为0后报错#powerpoint.Visible 1# 打开PPT文件并返回Presentation对象presentation powerpoint.Presentations.Open(ppt_file)for i, slide in enumerate(presentation.slides): #slide是幻灯片序列slide.Export(fslide_{i}.png, PNG)# 关闭PPT文件presentation.Close()# 退出PowerPoint应用程序powerpoint.Quit()presentation Noneprint(ppt_file分图完成)except Exception as e:print(分图时发生错误, str(e)) def merge_images(directory, png_file):try:Image.MAX_IMAGE_PIXELS 2 ** 40images [] # 存储图片对象for file in os.listdir(directory):file_path os.path.join(directory, file)if os.path.isfile(file_path) and file.lower().endswith(.png):image Image.open(file_path)images.append(image)if len(images) 0:print(未找到PNG格式的图片文件)return Nonemax_width max(image.size[0] for image in images) # 获取最大宽度total_height sum(image.size[1] for image in images) # 计算总高度final_image Image.new(RGBA, (max_width, total_height), (0, 0, 0, 0)) # 创建最终图像# 逐个粘贴图片到最终图像中y_offset 0for image in images:final_image.paste(image, (0, y_offset))y_offset image.size[1]final_image.save(png_file)print(已生成图片png_file)if final_image:for file in os.listdir(directory):file_path os.path.join(directory, file)if os.path.isfile(file_path) and file.lower().endswith(.png) and slide in file:os.remove(file_path)print(已删除图片file)except Exception as e:print(合并图片时发生错误, str(e))def select_directory():try:root Tk()root.withdraw()directory filedialog.askdirectory(title选择目录)ppt_files [f for f in os.listdir(directory) if f.endswith(.pptx)or f.endswith(.ppt)]for ppt_file in ppt_files:try:#print(directory directory)if ppt_file.lower().endswith(.pptx):png_file os.path.join(directory, ppt_file[:-5] .png)ppt_to_images(ppt_file) # PPT to imagemerge_images(directory, png_file) # image to imageselif ppt_file.lower().endswith(.ppt):png_file os.path.join(directory, ppt_file[:-4] .png)ppt_to_images(ppt_file) # PPT to imagemerge_images(directory, png_file) # image to imagesexcept Exception as e:print(处理PPT文件时发生错误跳过该文件, str(e))print(转换完成)except Exception as e:print(选择目录并转换PPT文件时发生错误, str(e))# 选择目录并转换PPT到PDF格式再将PDF转换为长图 select_directory() 代码2如下 import os import comtypes.client from tkinter import Tk, filedialog from pptx import Presentation from PIL import Image#PPT转换成图片def ppt_to_images(ppt_file, png_file):#presentation powerpoint.Presentations.Open(ppt_file)presentation Presentation(os.path.join(png_file, ppt_file))for i, slide in enumerate(presentation.slides): #slide是幻灯片序列slide.export(f{png_file}/slide_{i}.png) #将PPT转换成图片并保存到目录下print(PPT转换为图像完成)#将图片拼接成长图 def merge_images(ppt_path, output_file):images [Image.open(f{ppt_path}/{img}) for img in os.listdir(ppt_path) if img.endswith(.png)]widths, heights zip(*(img.size for img in images))total_height sum(heights)max_width max(widths)merged_image Image.new(RGB, (max_width, total_height))y_offset 0for img in images:merged_image.paste(img, (0, y_offset))y_offset img.size[1]merged_image.save(output_file)print(图像拼接完成)def ppt_to_pdf(ppt_path, pdf_file): #ppt路径和pdf的路径# 导入comtypes.client模块并创建PowerPoint应用程序对象powerpoint comtypes.client.CreateObject(Powerpoint.Application)# 设置PowerPoint应用程序为可见状态便于观察操作过程可选,修改为0后报错powerpoint.Visible 1# 打开PPT文件并返回Presentation对象presentation powerpoint.Presentations.Open(ppt_path)# 将打开的PPT文件导出为PDF文件第二个参数2表示导出为PDF格式presentation.ExportAsFixedFormat(pdf_file, 2)# 输出转换完成的信息print(ppt_path 转PDF完成)def select_directory():root Tk()root.withdraw()directory filedialog.askdirectory(title选择目录)ppt_files [f for f in os.listdir(directory) if f.endswith(.pptx)]for ppt_file in ppt_files:ppt_path os.path.join(directory, ppt_file) #ppt_path ppt的路径,拼接pptpdf_file os.path.join(directory, ppt_file[:-4] .pdf) #pdf文件png_file os.path.join(directory, ppt_file[:-4] .png)ppt_to_pdf(ppt_path, pdf_file)print(转换完成)# 选择目录并转换PPT到PDF格式再将PDF转换为长图 select_directory()
http://www.hkea.cn/news/14542076/

相关文章:

  • 机械行业做网站百度手机下载安装
  • 王色网站哈尔滨网页制作费用
  • 品牌商标购买网站网站ui设计给用户提交什么
  • 那些知名网站是外包做的欧美网站建设教程
  • 谷歌seo网站建设手机网站静态模板下载
  • 中国制造网外贸网站地方网站盈利模式
  • 购物小网站建设官方网站搭建要多少钱
  • 运动服饰网站建设需求分析wordpress下载模板
  • 绍兴网站建设公司哪家专业wordpress换域名代码
  • 第一次做网站选多大空间简历制作官网
  • 中国免费域名申请网站wordpress 新浪微博登入
  • 哪些网站可以做调查问卷计算机网站建设招聘
  • 十大网站app排行榜wordpress如何删除你好和设置菜单
  • 临沂在线做网站钦州房产网站建设
  • 网站设计主要包含3个方面化州网站建设公司
  • 桂林论坛网站有哪些未来前景比较好的行业有哪些
  • 网站管理系统安装app要有网站做基础知识
  • 最低的成本做网站河北建设工程有限公司
  • 平谷建站推广公司怎么做网站推广
  • 思途旅游网站建设系统wordpress 输入ftp
  • 单位门户网站建设方案如何做网站页面赚钱
  • 网站开发建设合同书typo wordpress theme
  • 网站域名备案服务电商平台营销策划方案
  • 小型企业网站的设计与实现搜索推广网站哪家做的最好
  • 做网站有陪标现象吗网络营销方案分析整理
  • 珠海市网站建设哪家好wordpress ico更改
  • asp做网站步骤微信电脑版官方下载
  • 福州网站建设印秀建设银行面试通知网站
  • 扬州润扬交通建设集团网站机械网站建设营销
  • 婚纱网站建设需求分析网站(网店)建设方案范文