Reducing PIL image size in memory

830 views Asked by At

i am grabbing PIL images with screengrab from the screen, saving them in a queue and writing them into a jpg image sequence.

I use a producer thread to capture and a worker to write the images down to disk.

However i noticed, that this queue gets really large really fast, even though the written output is not really that large, when compressen with jpg. That leads to the grabs being put into extended memory on the disk, making the write process even slower. Since my data comes in bursts, i can use up some time to write to the disk, but if the memory is written to disk, it gets just too slow.

Is there a way to compress the images before adding them into the queue?

cheers,

1

There are 1 answers

2
A T On

Here's an idea, merge the images as they come in.

After a set period of time or set amount merged, compress the image. Divide the image back into separate ones.

/profit