【教学类-84-01】时钟动物——动物头像01(动物头像+钟表盘+活动扣+纸质指针)

背景需求:

制作手表后,发现上面的指针没法运动(表盘小,只能绘画指针)

【教学类-82-01】20241209涂色手表制作1.0(表盘、表带)-CSDN博客文章浏览阅读798次,点赞26次,收藏22次。【教学类-82-01】20241209涂色手表制作1.0 https://blog.csdn.net/reasonsummer/article/details/144250493

【教学类-82-02】20241213涂色手表制作2.0(表盘、表带3.12CM)-CSDN博客文章浏览阅读1k次,点赞34次,收藏13次。【教学类-82-02】20241213涂色手表制作2.0(表盘、表带3.12CM) https://blog.csdn.net/reasonsummer/article/details/144447943所以我想做一个大号的时钟,并且可以配上指针进行活动

第1款:动物身体作为钟表盘

纯白色背景,卡通简笔画,母鸭//鼠/牛/虎/兔/龙/蛇/马/猴/鸡/狗//猫/熊猫,全身正面像,身体大而且胖,头小,可爱,萌,涂色书,简单笔画,卡通,黑白轮廓线,黑白轮廓线、黑白轮廓线、未着色,幼儿插图,线条画,没有背景,没有颜色,黑白漫画线条艺术:,线描,空背景,粗轮廓,清晰的线条,矢量线。简单,大,

第2款:动物头部作为钟表盘

关键词,纯白色背景,卡通简笔画,猪/鼠/牛/虎/兔/龙/蛇/马/猴/鸡/狗//猫/熊猫/鸭的头像,正面,脸大,脸胖,脸很圆,可爱,萌,涂色书,简单笔画,卡通,黑白轮廓线,黑白轮廓线、黑白轮廓线、未着色,幼儿插图,线条画,没有背景,没有颜色,黑白漫画线条艺术:,线描,空背景,粗轮廓,清晰的线条,矢量线。简单,大,

正方形动物头和长方形动物头身图一共928张

先用UIBOT+PS把所有白色部分都变成255,255,255

用程序去掉白色边,把图片最大化(不要统一图)

'''
去边后白色地方变成透明色
星火讯飞、阿夏
20241221
'''



print('----1、切掉上下左右的白色图层------')

import os
from PIL import Image

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

path=r'C:\蛇'
folder_path = path+r'\01修图'

# 留一点白边
white_edge=0
# C:\Users\jg2yXRZ\OneDrive\图片\20240817饮料甜甜圈\甜甜圈白色
import os
from PIL import Image

def find_non_white_pixel(image):
    width, height = image.size
    left, right, top, bottom = width, 0, height, 0

    for y in range(height):
        for x in range(width):
            r, g, b = image.getpixel((x, y))
            if r != 255 or g != 255 or b != 255:
                if x < left:
                    left = x
                if x > right:
                    right = x
                if y < top:
                    top = y
                if y > bottom:
                    bottom = y

    return left, right, top, bottom

def crop_image(image, left, right, top, bottom):
    return image.crop((left-white_edge, top-white_edge, right + white_edge, bottom + white_edge))



output_folder = path+r'\02切边图'
os.makedirs(output_folder, exist_ok=True)


for file_name in os.listdir(folder_path):
    if file_name.endswith(".jpg") or file_name.endswith(".png"):
        input_path = os.path.join(folder_path, file_name)
        image = Image.open(input_path)
        left, right, top, bottom = find_non_white_pixel(image)
        cropped_image = crop_image(image, left, right, top, bottom)
        output_path = os.path.join(output_folder, file_name)
        cropped_image.save(output_path)



# '''
# 去边后白色地方变成透明色,透明图片统一大小
# 星火讯飞、阿夏
# 20240817
# '''      

# print('----2、图片放大成为1024*1024------')
import os
from PIL import Image

# path=r'C:\Users\jg2yXRZ\OneDrive\图片\20240817饮料圆形'
# input_folder = path+r'\圆形切边图'
# output_folder = path+r'\圆形切边图透明'


# input_folder = path+r'\05切边图'
output_folder =path+r'\02切边图'
# output_folder = path+r'\04透明图'
newput_folder =path+r'\03统一图'
os.makedirs(newput_folder,exist_ok=True)

# 提取最大宽度的那张图片的尺寸
def get_max_width_and_height(fold_path):
    max_width = 0
    max_height = 0

    for file_name in os.listdir(fold_path):
        if file_name.endswith(".png") or file_name.endswith(".jpg") or file_name.endswith(".jpeg"):
            file_path = os.path.join(fold_path, file_name)
            img = Image.open(file_path)
            width, height = img.size
            if width > max_width:
                max_width = width
                max_height = height

    return max_width, max_height

fold_path = output_folder
max_width, max_height = get_max_width_and_height(fold_path)
print("最大宽度:", max_width)
print("最大高度:", max_height)

# 最大宽度: 724
# 最大高度: 869

# # # 自定义长宽
# max_width=1200 
# max_height=1200

# 统一所有图片大小
def resize_image(image_path, output_folder, new_image_name):
    img = Image.open(image_path)
    new_img = img.resize((max_width,max_height))
    new_img.save(os.path.join(output_folder, new_image_name))






for file in os.listdir(output_folder):
    if file.endswith('.png'):
        input_image_path = os.path.join(output_folder, file)
        new_image_name = f"{file[:-4]}.png"
        resize_image(input_image_path, newput_folder, new_image_name)





# '''
# 图片透明
# '''
# from PIL import Image
# import os

# def process_image(file_path):
#     img = Image.open(file_path)
#     img = img.convert("RGBA")
#     datas = img.getdata()

#     new_data = []
#     for item in datas:
#         if item[0] == 255 and item[1] == 255 and item[2] == 255:
#             new_data.append((255, 255, 255, 0))
#         else:
#             new_data.append(item)

#     img.putdata(new_data)
#     return img
# path=r'C:\Users\jg2yXRZ\OneDrive\桌面\20240806袜子配对\02袜子修图彩色白色'

# input_folder = path+r'\05切边图'
# output_folder = path+r'\06透明图'

# if not os.path.exists(output_folder):
#     os.makedirs(output_folder)

# for file_name in os.listdir(input_folder):
#     if file_name.endswith(".png") or file_name.endswith(".jpg") or file_name.endswith(".jpeg"):
#         input_file_path = os.path.join(input_folder, file_name)
#         output_file_path = os.path.join(output_folder, file_name)
#         processed_image = process_image(input_file_path)
#         processed_image.save(output_file_path)
import os
from PIL import Image

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

path=r'C:\蛇'
folder_path = path+r'\1 - 副本'

# 留一点白边
white_edge=0
# C:\Users\jg2yXRZ\OneDrive\图片\20240817饮料甜甜圈\甜甜圈白色
import os
from PIL import Image

def find_non_white_pixel(image):
    width, height = image.size
    left, right, top, bottom = width, 0, height, 0

    for y in range(height):
        for x in range(width):
            r, g, b = image.getpixel((x, y))
            if r != 255 or g != 255 or b != 255:
                if x < left:
                    left = x
                if x > right:
                    right = x
                if y < top:
                    top = y
                if y > bottom:
                    bottom = y

    return left, right, top, bottom

def crop_image(image, left, right, top, bottom):
    return image.crop((left-white_edge, top-white_edge, right + white_edge, bottom + white_edge))



output_folder = path+r'\02切边图'
os.makedirs(output_folder, exist_ok=True)


for file_name in os.listdir(folder_path):
    if file_name.endswith(".jpg") or file_name.endswith(".png"):
        input_path = os.path.join(folder_path, file_name)
        image = Image.open(input_path)
        left, right, top, bottom = find_non_white_pixel(image)
        cropped_image = crop_image(image, left, right, top, bottom)
        output_path = os.path.join(output_folder, file_name)
        cropped_image.save(output_path)





第1遍,打开“切边图”看看有没有图案还是有白边,需要把图片编号记录下来,这些图片放到PS里面,手动去除四边上的 黑点

因为这次是808张图,没有去边的图很多,所以我把他们挑选出来,然后用比对的方式,把原图里面的这些未去边的图案也挑选到一个文件夹,便于批量PS修图

切边图里跳出81个图片放到“切边图挑选”文件夹

用01修图和02切边图进行类比

# 去边图中筛选没有去边的编号,在原图里面把这些原图单独提取出来,便于PS

# Python,读取123文件夹下每一张图的名称,再读取234文件下每一张图片的名称,
# 判断那些234有的图片,123里没有,就把234里的这些多余的图片剪切放到345文件夹下
import os
import shutil

path=r'C:\蛇'
# 定义文件夹路径
folder1 =path+r'\02切边图'
folder2 = path+r'\01修图'
folder3 = path+r'\03需要修图'

# 获取每个文件夹中的文件名
files_in_folder1 = set(os.listdir(folder1))
files_in_folder2 = set(os.listdir(folder2))
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

阿夏reasonsummer

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

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

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

打赏作者

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

抵扣说明:

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

余额充值