|
|
|
@ -6,6 +6,8 @@ from PIL import Image
|
|
|
|
import imagehash
|
|
|
|
import imagehash
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
from config import Config
|
|
|
|
from config import Config
|
|
|
|
|
|
|
|
from pptx.opc.constants import RELATIONSHIP_TYPE as RT
|
|
|
|
|
|
|
|
from pptx.oxml import parse_xml
|
|
|
|
|
|
|
|
|
|
|
|
def get_copyright_image_paths():
|
|
|
|
def get_copyright_image_paths():
|
|
|
|
# 构建 assets/copyright-img 的相对路径
|
|
|
|
# 构建 assets/copyright-img 的相对路径
|
|
|
|
@ -60,12 +62,20 @@ def remove_copyright_images(pptx_path, copyright_image_paths):
|
|
|
|
# 定义要删除的关键字符数组(只删除文本框)
|
|
|
|
# 定义要删除的关键字符数组(只删除文本框)
|
|
|
|
del_text_keywords = ["Speaker name and title", "OfficePLUS", "Presenter name", "www.officeplus.cn", "第一PPT模板网-WWW.1PPT.COM"]
|
|
|
|
del_text_keywords = ["Speaker name and title", "OfficePLUS", "Presenter name", "www.officeplus.cn", "第一PPT模板网-WWW.1PPT.COM"]
|
|
|
|
# 定义要删除的关键字符数组(删除整页幻灯片)
|
|
|
|
# 定义要删除的关键字符数组(删除整页幻灯片)
|
|
|
|
del_text_keywords_slide = ["如需商用请您自行向版权方购买、获取商用版权。"]
|
|
|
|
del_text_keywords_slide = ["模板中使用的字体为开源字体","一站式办公内容服务平台"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 遍历所有幻灯片母版
|
|
|
|
|
|
|
|
# for sld_mstr in prs.slide_masters:
|
|
|
|
|
|
|
|
# theme_part = sld_mstr.part.part_related_by(RT.THEME)
|
|
|
|
|
|
|
|
# theme = parse_xml(theme_part.blob)
|
|
|
|
|
|
|
|
# sld_mstr.name = theme.get("name")
|
|
|
|
|
|
|
|
# print(sld_mstr.name)
|
|
|
|
|
|
|
|
|
|
|
|
# 遍历每一页幻灯片
|
|
|
|
# 遍历每一页幻灯片
|
|
|
|
for index, slide in enumerate(prs.slides):
|
|
|
|
for index, slide in enumerate(prs.slides):
|
|
|
|
# 遍历幻灯片中的每个形状
|
|
|
|
# 遍历幻灯片中的每个形状
|
|
|
|
for shape in slide.shapes:
|
|
|
|
for shape in slide.shapes:
|
|
|
|
|
|
|
|
|
|
|
|
# 检查形状是否为图片
|
|
|
|
# 检查形状是否为图片
|
|
|
|
if shape.shape_type == 13: # 13 表示图片
|
|
|
|
if shape.shape_type == 13: # 13 表示图片
|
|
|
|
# 临时保存图片
|
|
|
|
# 临时保存图片
|
|
|
|
@ -89,7 +99,6 @@ def remove_copyright_images(pptx_path, copyright_image_paths):
|
|
|
|
# 检查形状是否为文本框
|
|
|
|
# 检查形状是否为文本框
|
|
|
|
if shape.has_text_frame:
|
|
|
|
if shape.has_text_frame:
|
|
|
|
text_content = shape.text
|
|
|
|
text_content = shape.text
|
|
|
|
print(f"'{os.path.basename(pptx_path)}'在第 {index + 1} 页有文本框,内容为: '{text_content}'")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 检查文本内容是否包含要删除的关键字符数组中的任意字符
|
|
|
|
# 检查文本内容是否包含要删除的关键字符数组中的任意字符
|
|
|
|
if any(char in text_content for char in del_text_keywords_slide):
|
|
|
|
if any(char in text_content for char in del_text_keywords_slide):
|
|
|
|
|