In reference to the answer (how to convert dzi (deep zoom) files to full image)
I am a noob on this topic, please correct if I am wrong.
I am trying to create a multi-tiled tiff from .dzi (deep zoom image) format, how I am doing is:
(i) Pick the max level folder.
(ii) Vertically Stitch all the n columns of m rows (m_n.jpeg, I am referring to the images saved in this format) as png images. So they are occupying quite a considerable amount of space.
(iii) Finally, I horizontally merge all these vertical png images into a single full image png using pyvips.Image.write_to_file().
(iv) Finally using vips im_save, I convert the full image png to tiff.
My concern now is this process is taking almost 2 hours for it to make full image png for 30,000 base_tiles, and also it accounts to 10+ GB of size (Full Image png).
Is there any better and faster way to do the .dzi to tiff conversion?
libvips has an
arrayjoin
operator that can join a set of tiles together into a large image.You can use it like this (on the linux command-line):
That will load all the JPG image in the current directory, assemble them into a huge grid, 20 images across, and write as a TIFF pyramid. You'd need to check the size of your grid, obviously, and adjust the
across
parameter.The
$()
part sorts the filenames of the formx_y.jpg
by y first, then x, in numeric order. Without that, the tiles will be transposed, annoyingly.That's assuming overlap 0. If your tiles have an overlap, you'll need to set the
hspacing
andvspacing
options to control how tiles are positioned. For example:Will position the tiles every 254 pixels horizontally and vertically.
arrayjoin
has to be able to open all of the input images, so it needs a lot of file descriptors. Most linuxes default to a maximum of 1024 files open at once per process, so you'll probably need to raise that number. Usually you just edit a couple of config files and log out and in again. I set my system to 65536, but you can use any number.Windows has a hard limit of 2000 files per process which you cannot change. You'll need to assemble in sections on that platform.
Here's a worked example. First, create a deepzoom pyramid with no overlaps:
You can see it's made a grid of tiles 6 across and 9 down.
Now reassemble the tiles and write as a TIFF pyramid:
With pyvips it would be something like:
That took about 10 minutes and 6gb of ram to join 21,000 tiles on this laptop.