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.

Is it possible to define the pyramid level count when using tiffsave?

See original GitHub issue

I’m a newcomer to vips / pyvips (and GitHub and Coding for that matter) so please excuse any blatant errors within my question.

I’m working with whole slides images of histopathologic slides and was really happy to find that pyvips can actually write / save such files. Additionally, with pyvips.Image.openslideload one can make use of the OpenSlide library, which we utilize regularly. The problem is, that when I use pyvips.tiffsave and specify pyramid=True it changes the number of levels and I have not found a way out of this. The code I try to test this looks something like this:

import openslide
import pyvips

img_os = openslide.OpenSlide("SomeWSI.svs")
img_pv = pyvips.Image.openslideload("SomeWSI.svs")

save = "Test.svs"
img_pv.tiffsave(save, tile=True, compression='lzw', bigtiff=True, pyramid=True, Q=100)

img_new = openslide.OpenSlide("Test.svs")

print("Saved via pyvips: ", img_new.level_count)
print("Original file: ", img_os.level_count)

and the Output is:

Saved via pyvips:  10
Original file:  3

I’m surely missing something so any help would be much appreciated.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
jcupittcommented, Oct 13, 2019

By size, I mean number of pixels.

A 50,000 x 50,000 pixel image will have these layers:

0 = 50,000 1 = 25,000 2 = 12,500 3 = 6,250 4 = 3,125 5 = etc.

1reaction
jcupittcommented, Oct 13, 2019

The number of levels created by tiffsave is set by the size of the image. Larger images will need more levels.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Efficiently saving tiles to a bigtiff image - python - Stack Overflow
uint8 and I want to combine those into one BigTiff pyramidical image as fast as possible. My current approach is to create a...
Read more >
Image — pyvips 2.2.1 documentation - GitHub Pages
Small images are loaded via memory by default, use VIPS_DISC_THRESHOLD to set the definition of small. access (Access) – Hint the expected access...
Read more >
Image pyramids - libvips
It's fast and can generate pyramids for large images using only a small amount of memory. The TIFF writer, vips_tiffsave() can also build...
Read more >
tifffile - PyPI
Image data can be read as NumPy arrays or Zarr arrays/groups from strips, tiles, pages (IFDs), SubIFDs, higher order series, and pyramidal levels....
Read more >
Save files in graphics formats in Photoshop - Adobe Support
Some applications may not be able to read a CMYK file saved in JPEG format. ... Files with JPEG encoding can be printed...
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