Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

9
  • 1
    What does the asterisk variable holds ("*imgs")?
    – denisb411
    Commented Mar 31, 2020 at 21:44
  • 9
    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.
    – Kris
    Commented Apr 1, 2020 at 1:43
  • 2
    This will load all images into memory at the same time which can easily exhaust it.
    – Smiley1000
    Commented Jan 30, 2022 at 22:22
  • 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/…
    – Kris
    Commented Feb 21, 2022 at 12:22
  • 1
    @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/…
    – Kris
    Commented Feb 5 at 17:30