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.

Saving pyramid for multidimentional tiff.

See original GitHub issue

Hi John.

The tiff format should be able to support saving pyramids, I’ve asked that question here : https://github.com/ome/design/issues/104

in pyvips, I am able to save a 2D image with a pyramid fine, and then get the layer of the pyramid with the page argument in tiffload.

But if I save a tiff image with just 2 dimentions (for instance, z =2 ) and save it with the pyramid=True argument, it doesnt seem to work.

Minimum working example. teststack.tif is here : teststack.zip

import pyvips

img2d = pyvips.Image.tiffload("teststack.tif")
img3d = pyvips.Image.tiffload("teststack.tif", n=2)

img2d.tiffsave("img2d.tif", pyramid=True, tile=True)
img3d.tiffsave("img3d.tif", pyramid=True, tile=True)

img2dback = pyvips.Image.tiffload("img2d.tif", page=1)
img3dback = pyvips.Image.tiffload("img3d.tif", page=1)

print(img2dback)
print(img3dback)

Which gives

<pyvips.Image 300x300 uchar, 3 bands, srgb>
<pyvips.Image 600x600 uchar, 3 bands, srgb>

Is there any way to retrieve the pyramid of the image which contains an image in the z dimension?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jcupittcommented, Jul 26, 2021

Ooop, sorry, you’re right. As you say, 8.10 is subifd pyramids, 8.11 is jp2k.

I’ve added the doc updates to git master pyvips (will be 2.1.16), thanks for the reminder.

0reactions
petoorcommented, Jul 26, 2021

For anyone finding this issue. From @jcupitt’s previous answer.

Update: libvips 8.11 now supports OME-style subifd tiff image pyramids. The release notes have some background: https://libvips.github.io/libvips/2020/06/18/What’s-new-in-8.10.html#pyramids

He specifies libvips 8.11, but links to the 8.10 documentation. 8.10 seems to work just fine.

In 8.11 jpeg2000 is added. https://forum.image.sc/t/libvips-8-11-is-out-and-adds-support-for-ome-tiff-with-jpeg2000-compression/53787

In order to use jpeg2000 and not jpeg. change compression="jpeg" to compression="jp2k" However, it seems that “jp2k” is missing from https://libvips.github.io/pyvips/enums.html#pyvips.enums.ForeignTiffCompression

Read more comments on GitHub >

github_iconTop Results From Across the Web

Raster pyramids—ArcGIS Pro | Documentation
Pyramids are used to improve display performance. They are a downsampled version of the original raster dataset and can contain many downsampled layers....
Read more >
TIFF, Pyramid
Pyramid TIFFs are designed to support efficient zooming to different spatial resolutions, by storing the same image at multiple resolutions.
Read more >
SubResolution of Multi-Dimensional Data - Image.sc Forum
Now I am trying to implement saving of sub-resolutions. ... reading TIFF images, which don't expect TIFF data to be more than 2D...
Read more >
arcpy - Why ExportToTIFF() gets TIFFs without pyramids?
What I want to do is to add layers (which are TIFF files) one by one to the current MXD file, and export...
Read more >
Numpy array to generic-tiff (tiled) with pyramid structure
I have already tried using PIL, tifffile, libtiff but none of these libraries save the numpy array in the generic-tiff format compatible ...
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