I've got simple kivy app that takes in a three .tif files and creates a copy of each one. For some reason, Kivy is automatically exiting out of the for loop when ever something is done to an image. The function has no problems outside of kivy. No errors are being generated in my terminal either. It seems that there is a conflict with using pillow, but it is difficult to troubleshoot with no error message.
main.py
from kivy.app import App
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.lang.builder import Builder
from PIL import Image
import os
path_in = 'D:/TIF_STORAGE/'
path_out = 'D:/Convert/'
def manip_img(in_pth, out_pth):
i = 0
for img in os.listdir(in_pth):
img_open = Image.open(in_pth + img)
print(img_open)
# Does not get to the next step
conv = img_open.copy()
print(conv)
conv.save(out_pth + str(i) + '.tif')
i = i + 1
class WindowManager(ScreenManager):
pass
class MainWindow(Screen):
def run_main(self):
manip_img(path_in, path_out)
kv_main = Builder.load_file('main.kv')
class MyApp(App):
def build(self):
return kv_main
if __name__ == '__main__':
MyApp().run()
main.kv
WindowManager:
MainWindow:
<MainWindow>
BoxLayout:
orientation: "vertical"
Button:
text: "Run"
on_release: root.run_main()
Output
(GUI) D:\KIVY_new\testing>python main.py
[INFO ] [Logger ] Record log in C:\Users\name\.kivy\logs\kivy_21-12-03_63.txt
[INFO ] [Kivy ] v2.0.0
[INFO ] [Kivy ] Installed at "C:\Users\name\anaconda3\envs\GUI\lib\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.8.12 (default, Oct 12 2021, 03:01:40) [MSC v.1916 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "C:\Users\name\anaconda3\envs\GUI\python.exe"
[INFO ] [Factory ] 186 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] Backend used <glew>
[INFO ] [GL ] OpenGL version <b'4.6.0 NVIDIA 496.76'>
[INFO ] [GL ] OpenGL vendor <b'NVIDIA Corporation'>
[INFO ] [GL ] OpenGL renderer <b'NVIDIA GeForce RTX 2080/PCIe/SSE2'>
[INFO ] [GL ] OpenGL parsed version: 4, 6
[INFO ] [GL ] Shading version <b'4.60 NVIDIA'>
[INFO ] [GL ] Texture max size <32768>
[INFO ] [GL ] Texture max units <32>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [Text ] Provider: sdl2
[INFO ] [Base ] Start application main loop
[INFO ] [GL ] NPOT texture support is available
<PIL.TiffImagePlugin.TiffImageFile image mode=RGBA size=800x800 at 0x1CF5C1497F0>
(GUI) D:\KIVY_new\testing>
simple .py script
from PIL import Image
import os
path_in = 'D:/TIF_STORAGE/'
path_out = 'D:/Convert/'
def manip_img(in_pth, out_pth):
i = 0
for img in os.listdir(in_pth):
img_open = Image.open(in_pth + img)
print(img_open)
# Does get to the next step
conv = img_open.copy()
print(conv)
conv.save(out_pth + str(i) + '.tif')
i = i + 1
manip_img(path_in, path_out)
Output
(GUI) D:\>python delete_script.py
<PIL.TiffImagePlugin.TiffImageFile image mode=RGBA size=800x800 at 0x24155CC6DF0>
<PIL.Image.Image image mode=RGBA size=800x800 at 0x24155CA7130>
<PIL.TiffImagePlugin.TiffImageFile image mode=RGBA size=800x800 at 0x241578E3BE0>
<PIL.Image.Image image mode=RGBA size=800x800 at 0x24155CC6DF0>
<PIL.TiffImagePlugin.TiffImageFile image mode=RGBA size=800x800 at 0x241578E3760>
<PIL.Image.Image image mode=RGBA size=800x800 at 0x241578D5160>
from Kivy Exits Loop while using Pillow
No comments:
Post a Comment