convert icons to RGB if output is jpg, fixes #3073

This commit is contained in:
j 2018-01-18 10:58:18 +01:00
parent 5ac305c620
commit 03d5c677aa
2 changed files with 6 additions and 5 deletions

View file

@ -1,12 +1,11 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
from __future__ import division
import os import os
import sys
from PIL import Image from PIL import Image
from optparse import OptionParser from optparse import OptionParser
import sys
root_dir = os.path.normpath(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) root_dir = os.path.normpath(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
static_root = os.path.join(os.path.dirname(__file__), 'data') static_root = os.path.join(os.path.dirname(__file__), 'data')
@ -44,6 +43,8 @@ def render_icon(frame, timeline, icon):
# we're using jpegs with border-radius # we're using jpegs with border-radius
# mask_image = Image.open(os.path.join(static_root, 'iconMask.png')) # mask_image = Image.open(os.path.join(static_root, 'iconMask.png'))
# icon_image.putalpha(mask_image) # icon_image.putalpha(mask_image)
if icon.endswith('.jpg'):
icon_image = icon_image.convert('RGB')
icon_image.save(icon) icon_image.save(icon)
def main(): def main():

View file

@ -1,15 +1,13 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
from __future__ import division
import os import os
import sys
from PIL import Image from PIL import Image
from PIL import ImageDraw from PIL import ImageDraw
from optparse import OptionParser from optparse import OptionParser
from ox.image import drawText, wrapText from ox.image import drawText, wrapText
import sys
root_dir = os.path.normpath(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) root_dir = os.path.normpath(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
static_root = os.path.join(os.path.dirname(__file__), 'data') static_root = os.path.join(os.path.dirname(__file__), 'data')
@ -39,6 +37,8 @@ def render_list_icon(frames, icon):
mask_image = Image.open(os.path.join(static_root, 'iconMask.png')) mask_image = Image.open(os.path.join(static_root, 'iconMask.png'))
mask_image = mask_image.resize((icon_width, icon_height)) mask_image = mask_image.resize((icon_width, icon_height))
icon_image.putalpha(mask_image) icon_image.putalpha(mask_image)
if icon.endswith('.jpg'):
icon_image = icon_image.convert('RGB')
icon_image.save(icon) icon_image.save(icon)
def main(): def main():