【教学类-75-01】花边边框01(UIBOT图片背景填充白色)15CM手工纸

8 篇文章 1 订阅

前期研究

用了三天时间把所有通义万相下载的图片的背景改成纯白色。

UIBOt模拟PS修图

【教学类-74-01】袜子配对01(UIBOT图片背景填充白色)-CSDN博客文章浏览阅读1.4k次,点赞57次,收藏23次。【教学类-74-01】袜子配对01(UIBOT图片背景填充白色)https://blog.csdn.net/reasonsummer/article/details/140954279

修图后不同之处。

一、背景色变成纯白色(255,255,255)

肉眼无法分辨背景色是否是纯白,用PS全部修一遍,确保背景色都i纯白

二、图片大小从1MB变成500K,容量减少1/2、2/3

正方形汽车

灯具

图片小多了,制作PDF也会变快

背景需求:

今天我用通义万象下载了花边框

小花草简笔画边框素材。,简单笔画,卡通,黑白轮廓,轮廓加粗,轮廓加粗,未着色,插图,线条画,白色背景,白颜色,黑白漫画线条艺术:,白色背景,粗轮廓,清晰的线条,矢量线。简单,大,

使用UIBOT下载

使用UIBOT和PS去掉灰色背景

用EV录频发现200张图片一共修改了1小时6分钟。

视频展示:

比较长,看1分钟,就可以直接拉到最后

下载的图片放一个文件夹,复制一份,在新文件夹里的图片制作成PS白背景图

手动检查图片

删除相同的

手动挖空

素材准备:

图片素材

修图后的图片都是几百K,没有1MB以上

WORD模版

代码展示:

'''
15厘米手工纸话边框.PY
星火讯飞、阿夏
2024年8月11日
'''


import os
from PIL import Image, ImageDraw

print('----1、房屋切割成左右对称两片------------')

path=r'C:\Users\jg2yXRZ\OneDrive\桌面\20240811花边框bai'
old_path=path+r'\01花边框白'


# 获取文件夹下的所有图片文件
image_files = [os.path.join(old_path, f) for f in os.listdir(old_path) if f.endswith(('.jpg', '.jpeg', '.png'))]
print(image_files)

# 合并图案

import os,time
import shutil
from docx import Document
from docx.shared import Cm
from PIL import Image
from PyPDF2 import PdfFileMerger, PdfFileReader

from PIL import Image, ImageDraw, ImageFont
import os,random




# 将图片拆成8个一组
grouped_files = [image_files[i:i + 1] for i in range(0, len(image_files), 1)]
print(len(grouped_files))

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

print('----3、插入docx,制作pdf------------')
# 处理每一组图片
for group_index, group in enumerate(grouped_files):
    # 创建新的Word文档
    doc = Document(path+r'\花边框15.docx')
    # print(group)
    
    # 遍历每个单元格,并插入图片
    for cell_index, image_file in enumerate(group):
        # 计算图片长宽(单位:厘米)

        # 如果是空格,就跳过
        if not image_file:
            continue
    
        # 插入图片到单元格
        table = doc.tables[0]
        cell = table.cell(int(cell_index / 1), cell_index % 1)
        # 如果第一行有2个格子,两个数字都写2
        cell_paragraph = cell.paragraphs[0]
        cell_paragraph.clear()
        run = cell_paragraph.add_run()
        run.add_picture(image_file, width=Cm(13.53), height=Cm(13.53))
        
    # 保存Word文档
    doc.save(os.path.join(new_folder, f'{group_index + 1:03d}.docx'))
    


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

pdf_output_path = path+fr'\\01花边框15CM手工纸{int(len(grouped_files))}张共{int(len(image_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'))
        time.sleep(2)


# 合并零时文件里所有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)
time.sleep(2)






有141张1:1方形图片,所以生成时间比较长

最后结果PDF,用

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

阿夏reasonsummer

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

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

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

打赏作者

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

抵扣说明:

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

余额充值