1 Star 0 Fork 40

Jia/Pake

forked from Gitee 极速下载/Pake 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
icns2png.py 1.32 KB
一键复制 编辑 原始数据 按行查看 历史
汤威 提交于 2023-06-24 00:06 . :wrench:Configuration specification
"""
批量将icns文件转成png文件
Batch convert ICNS files to PNG files
"""
import os
try:
from PIL import Image
except ImportError:
os.system("pip install Pillow")
from PIL import Image
if __name__ == "__main__":
now_dir = os.path.dirname(os.path.abspath(__file__))
icons_dir = os.path.join(now_dir, "src-tauri", "icons")
png_dir = os.path.join(now_dir, "src-tauri", "png")
if not os.path.exists(png_dir):
os.mkdir(png_dir)
file_list = os.listdir(icons_dir)
file_list = [file for file in file_list if file.endswith(".icns")]
for file in file_list:
icns_path = os.path.join(icons_dir, file)
image = Image.open(icns_path)
image_512 = image.copy().resize((512, 512))
image_256 = image.copy().resize((256, 256))
image_32 = image.copy().resize((32, 32))
image_name = os.path.splitext(file)[0]
image_512_path = os.path.join(png_dir, image_name + "_512.png")
image_256_path = os.path.join(png_dir, image_name + "_256.ico")
image_32_path = os.path.join(png_dir, image_name + "_32.ico")
image_512.save(image_512_path, "PNG")
image_256.save(image_256_path, "ICO")
image_32.save(image_32_path, "ICO")
print("png file write success.")
print(f"There are {len(os.listdir(png_dir))} png picture in ", png_dir)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Rust
1
https://gitee.com/jia2019/Pake.git
git@gitee.com:jia2019/Pake.git
jia2019
Pake
Pake
master

搜索帮助