批量生成UE4图标

4 篇文章 0 订阅
2 篇文章 0 订阅

 

UE4 开发项目需要设置图标,但是PhotoShop挨个处理图片未免有些麻烦,

然后我就写了这样一个程序,使用非常方便,将logo图片拖拽入窗口

即可批量生成

icoTool 点击下载

图标抓取工具

 

 

代码分享出来:

# -*- coding: utf-8 -*-
from tkinter import *
from tkinter.messagebox import showinfo
import windnd
import MakeImg
import os

def dragged_files(files):
    msg = '\n'.join((item.decode('gbk') for item in files))
    res = MakeImg.MakeImage(msg)
    if res:
        # outPutPath = os.path.expanduser('~') + '\Desktop\AppIcon'
        showinfo('制作完成',"已保存到桌面\n\n 更多访问inite.cn")
    else:
        showinfo('制作失败', msg + "\n\n 访问inite.cn")


def main():
    MainWin = Tk()
    MainWin.title('Icon making tool')
    MainWin.resizable(width=False, height=False)
    screenwidth = MainWin.winfo_screenwidth()
    screenheight = MainWin.winfo_screenheight()
    size = '%dx%d+%d+%d' % (291, 255, (screenwidth - 291) / 2, (screenheight - 255) / 2)
    MainWin.geometry(size)
    windnd.hook_dropfiles(MainWin, func=dragged_files)
    # MainWin.iconbitmap("ue4.ico")


    TB1_Title = StringVar()
    TB1_Title.set('Please drag and drop img in')
    TB1 = Label(MainWin, textvariable=TB1_Title, anchor=W)
    TB1.place(x=65, y=104, width=200, height=24)

    MainWin.mainloop()


if __name__ == '__main__':
    main()



 

# -*- coding: utf-8 -*-
from PIL import Image
import sys
import os
outPutPath = os.path.expanduser('~') + '/Desktop/AppIcon/'

def MakeImage(ImageName):

    if not os.path.exists(outPutPath):
        os.mkdir(outPutPath)

    originImg = ''
    try:
        originImg = Image.open(ImageName)
    except:
        return False
    img0 = originImg.resize((57, 57), Image.ANTIALIAS)
    img1 = originImg.resize((114, 114), Image.ANTIALIAS)
    img2 = originImg.resize((120, 120), Image.ANTIALIAS)
    img3 = originImg.resize((180, 180), Image.ANTIALIAS)
    img4 = originImg.resize((72, 72), Image.ANTIALIAS)
    img5 = originImg.resize((144, 144), Image.ANTIALIAS)
    img6 = originImg.resize((76, 76), Image.ANTIALIAS)
    img7 = originImg.resize((152, 152), Image.ANTIALIAS)
    img8 = originImg.resize((167, 167), Image.ANTIALIAS)
    img9 = originImg.resize((1024, 1024), Image.ANTIALIAS)

    img0.save(outPutPath + 'dAppIcon57x57.png', "png")
    img1.save(outPutPath + 'eAppIcon114x114.png', "png")
    img2.save(outPutPath + 'fAppIcon120x120.png', "png")
    img3.save(outPutPath + 'gAppIcon180x180.png', "png")
    img4.save(outPutPath + 'hAppIcon72x72.png', "png")
    img5.save(outPutPath + 'iAppIcon144x144.png', "png")
    img6.save(outPutPath + 'gAppIcon76x76.png', "png")
    img7.save(outPutPath + 'kAppIcon152x152.png', "png")
    img8.save(outPutPath + 'lAppIcon167x167.png', "png")
    img9.save(outPutPath + 'mAppIcon1024x1024.png', "png")

    # 20x20
    img10 = originImg.resize((20, 20), Image.ANTIALIAS)
    img11 = originImg.resize((40, 40), Image.ANTIALIAS)
    img12 = originImg.resize((60, 60), Image.ANTIALIAS)
    img10.save(outPutPath + '1AppIcon20x20.png', "png")
    img11.save(outPutPath + '2AppIcon40x40.png', "png")
    img12.save(outPutPath + '3AppIcon60x60.png', "png")

    # 29x29
    img13 = originImg.resize((29, 29), Image.ANTIALIAS)
    img14 = originImg.resize((58, 58), Image.ANTIALIAS)
    img15 = originImg.resize((87, 87), Image.ANTIALIAS)
    img13.save(outPutPath + '4AppIcon29x29.png', "png")
    img14.save(outPutPath + '5AppIcon59x59.png', "png")
    img15.save(outPutPath + '6AppIcon87x87.png', "png")

    # 40x40
    img16 = originImg.resize((40, 40), Image.ANTIALIAS)
    img17 = originImg.resize((80, 80), Image.ANTIALIAS)
    img18 = originImg.resize((120, 120), Image.ANTIALIAS)
    img16.save(outPutPath + '7AppIcon40x40.png', "png")
    img17.save(outPutPath + '8AppIcon80x80.png', "png")
    img18.save(outPutPath + '9AppIcon120x120.png', "png")

    # 50
    img19 = originImg.resize((50, 50), Image.ANTIALIAS)
    img20 = originImg.resize((100, 100), Image.ANTIALIAS)
    img21 = originImg.resize((58, 58), Image.ANTIALIAS)
    img19.save(outPutPath + 'aAppIcon50x50.png', "png")
    img20.save(outPutPath + 'bAppIcon100x100.png', "png")
    img21.save(outPutPath + 'cAppIcon58x58.png', "png")
    return True


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值