T
T
TestVDK2014-01-22 07:12:13
Python
TestVDK, 2014-01-22 07:12:13

How to merge many large images?

Hello.
I need to make a single jpg file from a bunch of my images.
It will be in the form of a square with a side of 12 files, each of which has an image. (5910x5910). One such file currently occupies 3.5mb.
I don't have some files - in the final image these places will be replaced by white squares.
At the moment I'm using a computer with 2GB of RAM.
Programs:
1) python 2.7 + PIL. When I try to create an image with a resolution of 20k * 10k - my computer freezes. So I would do by inserting into a new image in turn all available
2) imagemagick. I found this program in the search - in console mode it can glue images, but when gluing 4 of my images into 1, it also freezes for a long time.
There is also a computer with 16GB of RAM, I have not tried it yet.
Advise what to do.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Spetros, 2014-01-22
@Spetros

In order to create one large image from several others, these several images need to be unpacked, glued, and only then compressed into the required format. An image with a resolution of 20k * 10k, together with the source files in uncompressed form, will not fit in 2GB of RAM.
Try using a 16GB computer.

Z
zed, 2014-01-23
@zedxxx

I don't know if you are limited to scripts only or if you can use something other than them, but I advise you to use the libjpeg library (or its pumped version libjpeg-turbo) and its functions for line-by-line reading and writing to a jpeg file (scanline methods). In this case, you will need very little memory (a few megabytes) to complete your task, but you will have to work with the low-level api of the C library.
The same library has one more feature - lossless merging of jpeg files. For this, even the jpegtran console utility was written, which comes in the archive with the library. Only this chip already uses the RAM to the fullest and 16GB will be very useful to you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question