pyvips icon indicating copy to clipboard operation
pyvips copied to clipboard

issue creating 120k x 60k image using pyvips.Image.insert: process is getting killed when RAM is full

Open malay-pal opened this issue 2 years ago • 3 comments

I have the corordinates of all the individual tiles in a canvas. I tried to create the whole canvas using pyvips.Image.insert. When I looked at the RAM usage of the process, I see that it keeps on growing until it fills up entire RAM and then the process is getting killed. After going through the documentation, I found that mosaic, arrayjoin, composite methods might be the possible solution. However, I am not able to understand the underlying (conceptual) differences between them. Kindly explain these methods with some example and some use cases, if possible.

malay-pal avatar Apr 04 '23 15:04 malay-pal

Is it possible to use pyvips with mmap to create a large file on disk and then use insert method to generate the large image?

malay-pal avatar Apr 05 '23 18:04 malay-pal

Not sure if I am doing something wrong:

import pyvips
source = pyvips.Source.new_from_file("image.jpg")

Traceback (most recent call last): File "fd1.py", line 34, in source = pyvips.Source.new_from_file("image.jpg") File "/home/malay/miniconda3/envs/py3.8/lib/python3.8/site-packages/pyvips/vsource.py", line 60, in new_from_file pointer = vips_lib.vips_source_new_from_file(_to_bytes(filename)) File "/home/cloud-ops/miniconda3/envs/py3.8/lib/python3.8/site-packages/cffi/api.py", line 912, in getattr make_accessor(name) File "/home/cloud-ops/miniconda3/envs/py3.8/lib/python3.8/site-packages/cffi/api.py", line 907, in make_accessor raise AttributeError(name) AttributeError: vips_source_new_from_file

import pyvips
image = pyvips.Image.new_temp_file('.tif')

Traceback (most recent call last): File "fd1.py", line 35, in image = pyvips.Image.new_temp_file('.tif') File "/home/malay/miniconda3/envs/py3.8/lib/python3.8/site-packages/pyvips/vimage.py", line 701, in new_temp_file raise Error('unable to make temp file') pyvips.error.Error: unable to make temp file tempfile: unable to make temporary file /tmp/.tif

ubuntu 18.04, tested with python 3.8 and 3.11. working on macOS.

malay-pal avatar Apr 06 '23 18:04 malay-pal

Hello, sorry for the delay in responding, I'll post a demo program that does this some time this weekend.

jcupitt avatar Apr 07 '23 10:04 jcupitt