【教学类-70-01】20240728一个茶壶两个茶杯(果茶)

背景需求:

用通义万相下载简笔画茶壶、茶杯

茶杯,简单笔画,卡通,黑白,未着色,幼儿插图,线条画,没有背景,没有颜色,黑白漫画线条艺术:,空背景,粗轮廓,清晰的线条,矢量线。简单,大,

茶壶,简单笔画,卡通,黑白,未着色,幼儿插图,线条画,没有背景,没有颜色,黑白漫画线条艺术:,空背景,粗轮廓,清晰的线条,矢量线。简单,大,
 

用Photoshop把图片上的小点子、表情、眼睛等图案修掉

利用模版,设计一个大茶壶,两个小茶壶的A4学具

图像素材准备
 

代码展示

# '''
# 21*29.7(19.52)长方形A4 
# 目的:一大二小茶壶茶杯(对称+裁剪+手环帽子等)
# 作者:阿夏
# 时间:2024年7月27日17:27
# '''

import os
import time
import shutil
from docx import Document
from docx.shared import Cm, Pt, Inches, RGBColor
from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
from docx.oxml.ns import qn
from PyPDF2 import PdfFileMerger, PdfFileReader
from docxtpl import DocxTemplate
import pandas as pd

print('----------第1步:提取所有的幼儿照片的路径------------')

# 读取123文件夹下的所有图片
path = r'C:\Users\jg2yXRZ\OneDrive\桌面\果茶'
teapot_folder = os.path.join(path, '01茶壶')  # 100
teacup_folder = os.path.join(path, '00茶杯')  # 76 以这里的数量为准

teapot_files = [os.path.join(teapot_folder, f) for f in os.listdir(teapot_folder) if f.endswith('.jpg') or f.endswith('.png')]
teacup_files = [os.path.join(teacup_folder, f) for f in os.listdir(teacup_folder) if f.endswith('.jpg') or f.endswith('.png')]
# print(teacup_files)

# 创建临时文件夹
new_folder = path+r'\零时文件夹'
os.makedirs(new_folder, exist_ok=True)

print('----------第3步:一张大茶壶,2个小茶杯 ------------')

for nn in range(0,int(len(teacup_files))):      # 读取图片的全路径  的数量 31张
    doc = Document(path+r'\果茶.docx')
    
    teacup_figures=teacup_files[nn]           # 茶杯的图片
    teapot_figures=teapot_files[nn]           # 茶壶的图片

    table = doc.tables[0]          # 4567(8)行
#
    # 写入1张大图
    run=doc.tables[0].cell(0,0).paragraphs[0].add_run()        # # 图片位置 第一个表格的0 3 插入照片
    run.add_picture(r'{}'.format(teapot_figures),width=Cm(19.5),height=Cm(19.5))
    table.cell(0,0).paragraphs[0].alignment = WD_PARAGRAPH_ALIGNMENT.CENTER #居中 
    # 写入2张小图
    for tt in range(2):
        run=doc.tables[0].cell(tt,1).paragraphs[0].add_run()        # # 图片位置 第一个表格的0 3 插入照片
        run.add_picture(r'{}'.format(teacup_figures),width=Cm(8.8),height=Cm(8.8))
        table.cell(tt,1).paragraphs[0].alignment = WD_PARAGRAPH_ALIGNMENT.CENTER #居中 

    doc.save(new_folder+fr'\{nn:03d}.docx')   
    time.sleep(3)
    
print('----------第4步:把都有PDF合并为一个打印用PDF------------')

# 将10个docx转为PDF
import os
from docx2pdf import convert
from PyPDF2 import PdfFileMerger

pdf_output_path = path+fr"\果茶茶壶茶杯({len(teacup_files)}人共{len(teacup_files)}份).pdf"

# 将所有DOCX文件转换为PDF
for docx_file in os.listdir(new_folder):
    if docx_file.endswith('.docx'):
        docx_path = os.path.join(new_folder, docx_file)
        convert(docx_path, docx_path.replace('.docx', '.pdf'))


# 合并零时文件里所有PDF文件
merger = PdfFileMerger()
for pdf_file in os.listdir(new_folder):
    if pdf_file.endswith('.pdf'):
        pdf_path = os.path.join(new_folder, pdf_file)
        merger.append(pdf_path)
time.sleep(2)

# 保存合并后的PDF文件
merger.write(pdf_output_path)
merger.close()

# 删除输出文件夹
shutil.rmtree(new_folder)
# shutil.rmtree(zheng_path)
# shutil.rmtree(fan_path)
time.sleep(10)

    

 

作品展示

  • 9
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

阿夏reasonsummer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值