-
The code below works fine on Windows, which allows me to preview in low resolution using a py5 window and generate higher resolution frames using multiprocessing for the final output. However, no frames are saved using
Has anyone ran into something similar? def make_image(i):
img = py5.create_image_from_numpy(julia(1024, 1024, x=x, y=y, zoom=zooms[i]), 'RGB')
img.save('vids/julia/{i:06d}.png')
print(i)
def draw():
global i
img = py5.create_image_from_numpy(julia(py5.width, py5.height, x=x, y=y, zoom=zooms[i]), 'RGB')
py5.image(img, 0, 0)
i+=1 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hello, @phitaylr ! When you say multiprocessing, are you referring to Python's multiprocessing library? Can you explain more about what you are doing? I've never used that with py5 and I suspect there might be some hidden pitfalls. I do know that Python's multiprocessing library works very differently on Windows because Windows OS doesn't support forking like linux does. Is your Also, you might have a typo in In any case, I think you'd get better performance in from PIL import Image
def make_image(i):
img = Image.fromarray(julia(1024, 1024, x=x, y=y, zoom=zooms[i]), mode='RGB')
img.save(f'vids/julia/{i:06d}.png')
print(i) When py5 saves an image or frame it is actually using PIL, not Processing's save functionality. PIL can save in more formats and has more extensive functionality. Creating Py5Image objects and then saving them right away is going to be slower because you are creating unneeded Java objects. Better to go PIL Images directly. |
Beta Was this translation helpful? Give feedback.
Hello, @phitaylr !
When you say multiprocessing, are you referring to Python's multiprocessing library? Can you explain more about what you are doing? I've never used that with py5 and I suspect there might be some hidden pitfalls. I do know that Python's multiprocessing library works very differently on Windows because Windows OS doesn't support forking like linux does. Is your
julia()
function using multiprocessing?Also, you might have a typo in
make_image(i)
. Did you mean to typeimg.save(f'vids/julia/{i:06d}.png')
?In any case, I think you'd get better performance in
make_image(i)
if you used PIL Images instead of py5's Py5Image objects. For example: