mirror of
https://github.com/keymanapp/keyman.git
synced 2026-10-06 14:07:32 +00:00
Save ico/bmp files to png
This commit is contained in:
parent
0f9432ae25
commit
2beb0aa8f6
3 changed files with 13 additions and 16 deletions
|
|
@ -28,8 +28,9 @@ def checkandsaveico(icofile):
|
|||
Args:
|
||||
icofile (str): path to ico file
|
||||
"""
|
||||
bmpfile = icofile
|
||||
if icofile.endswith('.ico'):
|
||||
name, ext = os.path.splitext(icofile)
|
||||
bmpfile = name + ".bmp"
|
||||
if ext == '.ico':
|
||||
im = Image.open(icofile)
|
||||
im = im.convert('RGBA')
|
||||
im2 = im
|
||||
|
|
@ -38,21 +39,16 @@ def checkandsaveico(icofile):
|
|||
if num > 160 and colour == (0, 0, 0, 0):
|
||||
logging.info("checkandsaveico:" + icofile + " mostly black so changing black to white")
|
||||
im2 = changeblacktowhite(im)
|
||||
bmpfile = icofile + ".bmp"
|
||||
im2.save(bmpfile)
|
||||
|
||||
try:
|
||||
im3 = Image.open(bmpfile)
|
||||
im4 = im3;
|
||||
im4 = im4.resize([64, 64], Image.ANTIALIAS)
|
||||
im4.save(icofile + ".png", "png")
|
||||
except (IOError, OSError) as error:
|
||||
im4 = im3.resize([64, 64], Image.ANTIALIAS)
|
||||
im4.save(name + '.png', 'png')
|
||||
except (IOError, OSError) as e:
|
||||
logging.error("Cannot convert %s to png", icofile)
|
||||
pass
|
||||
|
||||
if bmpfile.endswith('.ico.bmp'):
|
||||
os.remove(bmpfile)
|
||||
|
||||
|
||||
def extractico(kmxfile):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -175,19 +175,19 @@ class ViewInstalledWindow(ViewInstalledWindowBase):
|
|||
|
||||
if install_area == InstallArea.IA_USER:
|
||||
welcome_file = os.path.join(user_keyboard_dir(kmpdata['packageID']), "welcome.htm")
|
||||
icofile = os.path.join(user_keyboard_dir(kmpdata['packageID']), kmpdata['packageID'] + ".ico.png")
|
||||
icofile = os.path.join(user_keyboard_dir(kmpdata['packageID']), kmpdata['packageID'] + ".png")
|
||||
if not os.path.isfile(icofile):
|
||||
icofile = os.path.join(user_keyboard_dir(kmpdata['packageID']), kmpdata['keyboardID'] + ".ico.png")
|
||||
icofile = os.path.join(user_keyboard_dir(kmpdata['packageID']), kmpdata['keyboardID'] + ".png")
|
||||
elif install_area == InstallArea.IA_SHARED:
|
||||
welcome_file = os.path.join("/usr/local/share/keyman", kmpdata['packageID'], "welcome.htm")
|
||||
icofile = os.path.join("/usr/local/share/keyman", kmpdata['packageID'], kmpdata['packageID'] + ".ico.png")
|
||||
icofile = os.path.join("/usr/local/share/keyman", kmpdata['packageID'], kmpdata['packageID'] + ".png")
|
||||
if not os.path.isfile(icofile):
|
||||
icofile = os.path.join("/usr/local/share/keyman", kmpdata['packageID'], kmpdata['keyboardID'] + ".ico.png")
|
||||
icofile = os.path.join("/usr/local/share/keyman", kmpdata['packageID'], kmpdata['keyboardID'] + ".png")
|
||||
else:
|
||||
welcome_file = os.path.join("/usr/share/keyman", kmpdata['packageID'], "welcome.htm")
|
||||
icofile = os.path.join("/usr/share/keyman", kmpdata['packageID'], kmpdata['packageID'] + ".ico.png")
|
||||
icofile = os.path.join("/usr/share/keyman", kmpdata['packageID'], kmpdata['packageID'] + ".png")
|
||||
if not os.path.isfile(icofile):
|
||||
icofile = os.path.join("/usr/share/keyman", kmpdata['packageID'], kmpdata['keyboardID'] + ".ico.png")
|
||||
icofile = os.path.join("/usr/share/keyman", kmpdata['packageID'], kmpdata['keyboardID'] + ".png")
|
||||
if not os.path.isfile(icofile):
|
||||
icofile = find_keyman_image("icon_kmp.png")
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import logging
|
|||
import sys
|
||||
import os
|
||||
from keyman_config import __version__
|
||||
from keyman_config.uninstall_kmp import uninstall_kmp
|
||||
|
||||
import datetime
|
||||
import time
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue