Skip to main content
15 events
when toggle format what by license comment
Feb 5 at 17:30 comment added Kris @LoganPrice Sorry for the late reply. I believe you can change that behavior via the disposal=... keyword argument, cf. pillow.readthedocs.io/en/stable/handbook/…
May 30, 2023 at 2:33 comment added Logan Price Technically worked, but I noticed since I used transparency, that each frame stays drawn on the screen and the next frame simply gets stacked on top. By the end of the gif, it looks like a bunch of images stacked on top of each other. Is there a way to specify that each frame gets destroyed after it is shown?
Jan 21, 2023 at 13:03 history edited Kris CC BY-SA 4.0
added 11 characters in body
Jan 20, 2023 at 19:13 comment added seizethedata Thanks, worked perfectly for me, but had to import ExitStack like this: from contextlib import ExitStack
Nov 23, 2022 at 4:38 comment added Kris You're right. I updated the example. I hope it's still readable for most people.
Nov 23, 2022 at 4:36 history edited Kris CC BY-SA 4.0
Ensure that opened files are closed
Nov 22, 2022 at 14:53 comment added TheDronist I find this answer very useful, however, if you execute this in an interactive shell (ipython), the images remain open as long as the shell runs. Therefore a closing method is required: for t in (Image.open(f) for f in sorted(glob.glob(fp_in))): t.close()
Feb 21, 2022 at 12:25 history edited Kris CC BY-SA 4.0
avoid loading all images in memory
Feb 21, 2022 at 12:22 comment added Kris You're right, I'll edit it to use iterators instead. Note that PIL is clever enough not to load all images in memory, cf. github.com/python-pillow/Pillow/blob/main/src/PIL/…
Jan 30, 2022 at 22:22 comment added Smiley1000 This will load all images into memory at the same time which can easily exhaust it.
Jan 13, 2022 at 20:39 history edited Innat CC BY-SA 4.0
edited body
Sep 14, 2020 at 0:03 history edited Kris CC BY-SA 4.0
added 90 characters in body
Apr 1, 2020 at 1:43 comment added Kris That's a python language feature. It does iterable unpacking. You can roughly think of it as unpacking x = [a, b, c] to *x which can be thought of as a, b, c (without the enclosing brackets). In function calls these are synonymous: f(*x) == f(a, b, c). In tuple unpacking it's particularly useful in cases where you want to split an iterable into a head (first element) and a tail (the rest), which is what I do in this example.
Mar 31, 2020 at 21:44 comment added denisb411 What does the asterisk variable holds ("*imgs")?
Sep 2, 2019 at 5:24 history answered Kris CC BY-SA 4.0