代码库初始化
This commit is contained in:
1 parent
07786ab323
commit
4334694551
851 files changed
+42626
No files matched your search
@@ -0,0 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from PIL import Image
|
||||
src = r"e:\MCStudioDownload\work\3027246179@qq.com\Cpp\AddOn\309c2d420bc84ee986db9cdd070ff02a\_sa_hanhua_out\_tmp\jianbing_gen.jpg"
|
||||
dst = r"e:\MCStudioDownload\work\3027246179@qq.com\Cpp\AddOn\309c2d420bc84ee986db9cdd070ff02a\resource_pack_t7eJjrxY\textures\items\jianbing.png"
|
||||
im = Image.open(src).convert("RGBA")
|
||||
# 生成图为 JPG,无透明通道;先裁切到主体并缩放到16x16等比例,再把背景置为透明
|
||||
# 直接等比缩放整图到16x16(原图为方形,保持比例不变形)
|
||||
resized = im.resize((16, 16), Image.LANCZOS)
|
||||
# 对接近白色的背景擦除为透明(JPG无alpha)
|
||||
pix = resized.load()
|
||||
for y in range(16):
|
||||
for x in range(16):
|
||||
r, g, b, a = pix[x, y]
|
||||
if r > 245 and g > 240 and b > 230:
|
||||
pix[x, y] = (r, g, b, 0)
|
||||
resized.save(dst)
|
||||
print("saved", resized.size)
|
||||
Reference in new issue
Block a user