question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: OOM during composite and write large PNGs

See original GitHub issue

I am trying to write large PNGs (its on a Kubernetes node with 8GB RAM).

  • I seem to be able to write large PNGs (e.g. 70MB on disk) by taking a single “small” sample PNG and writing it multiple times to a large output image using .composite
  • In my application, when i try to stream many PNGs and composite them onto a large output image it OOMs.

My question is about expected behavior and what is the pattern to do this … should it be possible to composite any number of “small” images streamed (i.e. loaded from S3 into memory one image at a time) and composite them onto a large output image and save to file? Assume these “small” images are much smaller in memory than 8GB.

I had assumed the the write would sequentially write out the PNG without holding the streamed images in memory but i must be mistaken? It is confusing to me right now that my first test that writes a single PNG works but my true test of writing out different images does not.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jcupittcommented, Jul 24, 2022

The disc threshold is the size of the uncompressed image, so width * height * bands * sizeof( element ).

You can put the unit after the number, so eg. “1gb”, “10mb”, “100kb”, etc.

There’s a page in the docs covering libvips image opening which gives some background:

https://www.libvips.org/API/current/How-it-opens-files.html

0reactions
Bordacommented, Jul 24, 2022

You can try tuning settings for VIPS_CONCURRENCY and VIPS_DISC_THRESHOLD

This looks useful! are both available also for python scripts? Could you please share what units for VIPS_DISC_THRESHOLD are used (MB or pixels)?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flutter easily composite / overlay PNG images from the assets ...
Use canvas.drawAtlas in my own Painter; use the image library (which seems a bit overkill in this case. Couldn't find any working example...
Read more >
How to insert multiple images in one figure using LaTeX? - TeX
You can just put multiple \includegraphics commands into your figure environment. Keep it mind that figure is just a logical, ...
Read more >
Displayables — Ren'Py Documentation
When a Ren'Py function or variable expects a displayable, there are five ... image eileen composite = Composite( (300, 600), (0, 0), "body.png",...
Read more >
RFC 2083 - PNG (Portable Network Graphics) Specification ...
This specification defines the Internet Media Type image/png. ... display device they are using and room lighting, to present the image to the...
Read more >
JPEG vs. PNG: Which one should you use? - Adobe
JPEG and PNG are two of the most widely used image file formats. ... between JPEGs and PNGs and find out when to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found