如何在PNG
(JPEG
)上没有Pillow
的情况下将kivy
文件转换为Python
?
任何帮助将不胜感激。谢谢!
答案 0 :(得分:2)
使用Kivy CoreImage从png转换为jpg。
from kivy.core.image import Image as CoreImage
img = CoreImage("linux.png")
img.save("linux.jpg")
from kivy.uix.screenmanager import Screen
from kivy.core.image import Image as CoreImage
from kivy.lang import Builder
from kivy.base import runTouchApp
Builder.load_string('''
#:kivy 1.10.1
<Demo>:
img_png: img_png
img_jpg: img_jpg
RelativeLayout:
Image:
id: img_png
pos_hint: {"left": 1, 'bottom': 1}
size_hint: 0.5, 1
allow_stretch: True
RelativeLayout:
Image:
id: img_jpg
pos_hint: {"right": 1, 'bottom': 1}
size_hint: 0.5, 1
allow_stretch: True
''')
class Demo(Screen):
def __init__(self, **kwargs):
super(Demo, self).__init__(**kwargs)
img = CoreImage("linux.png")
img.save("linux.jpeg")
self.img_png.source = "linux.png"
self.img_jpg.source = "linux.jpeg"
runTouchApp(Demo())