invalid tile byte count when using writing tif file
See original GitHub issueWhen trying to write a black-white tif file (a tumor mask for breast cancer H&E slides) I am running into an error which I have been trying to solve for the last few hours, but to no avail. I was wondering if you would happen to know what could be the cause of this. I have also tried to solve it by replacing it with a conda installation, but with the same result.
- example tif file and code included below
Installation information
linux: 5.8.14-arch1-1
python: 3.8
vips: https://github.com/libvips/libvips/releases/download/v8.11.2/vips-8.11.2.tar.gz
libjpeg: libjpeg-turbo8-dev
ibgtk2.0-dev
libgsf-1-dev
libtiff5-dev
pyvips: 2.1.15
sample code:
mask_fname = 'tumor_010_mask.tif'
image = pyvips.Image.new_from_file(mask_fname)
# does not work, gives TIFFFillTile errors
arr = np.ndarray(buffer=image.write_to_memory())
# does not work, gives TIFFFillTile errors
image.write_to_file('test.tif')
Whenever I try to run the above sample code, I get the following errors:
---------------------------------------------------------------------------
Error Traceback (most recent call last)
<ipython-input-29-21eb559af30f> in <module>
1 image = pyvips.Image.new_from_file(mask_fname, access=pyvips.Access.SEQUENTIAL)
2
----> 3 arr = np.ndarray(buffer=image.write_to_memory(),
4 dtype=dict_inverse(dtype_to_format)[image.format],
5 shape=[image.height, image.width, image.bands])
/usr/local/lib/python3.8/site-packages/pyvips/vimage.py in write_to_memory(self)
619 pointer = vips_lib.vips_image_write_to_memory(self.pointer, psize)
620 if pointer == ffi.NULL:
--> 621 raise Error('unable to write to memory')
622 pointer = ffi.gc(pointer, glib_lib.g_free)
623
Error: unable to write to memory
TIFFFillTile: 0: Invalid tile byte count, tile 0
TIFFFillTile: 0: Invalid tile byte count, tile 1
TIFFFillTile: 0: Invalid tile byte count, tile 2
TIFFFillTile: 0: Invalid tile byte count, tile 3
TIFFFillTile: 0: Invalid tile byte count, tile 4
TIFFFillTile: 0: Invalid tile byte count, tile 5
TIFFFillTile: 0: Invalid tile byte count, tile 6
.
.
.
TIFFFillTile: 0: Invalid tile byte count, tile 189
TIFFFillTile: 0: Invalid tile byte count, tile 190
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
[gdal-dev] gdal_translate: invalid tile byte error
On 12-03-17 01:15 PM, Andrea Peri wrote: > Hi, > I'm try-ing to create a set of tiff tiled with internal overviews from...
Read more >libtiff new security issue (second issue from PoC for CVE-2015 ...
[used with the 3 sample TIF files] BEFORE the update: all these commands/files yielded ... TIFFFillTile: 0: Invalid tile byte count, tile 1....
Read more >Openslide/VIPS/IM debugging - Andrew Mailman Mailing Lists
Using $vips openslideload --level 3 MIRAX_SLIDE.mrxs slide.tiff[tile ... 0: Invalid tile byte count, tile 219. openslide-write-png: ...
Read more >Unable to write to memory · Issue #213 · libvips/pyvips - GitHub
Hello, I use pyvips for reading big ndpi files. ... TIFFFillStrip: Invalid strip byte count 0, strip 12 ... vips2tiff: TIFF write tile...
Read more >Troubles with TIFF: StripOffsets inconsistent with ...
In our workflows the first tool to check TIFF files is JHOVE – if an ... Byte Counts : (Binary data 81 bytes,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Then it seems that something is going wrong within the ASAP pipeline. As a sanity check I have read an original tissue file into asap and then wrote it back to tif.
The result is that pyvips is able to read the resulting array into memory, and write it to tif without any problem. The only repeating problem is that the masks generated by the asap pipeline are able to be processed into pyvips.
As a workaround, I have been able to come up with a rather intensive workaround: I can read the culprit masks into memory using ASAP, and then read the resulting array into pyvips using read_from_buffer. Then, I can simply save the resulting array using pyvips. The resulting file will have no problem being handled by pyvips.
As for the problem itself: I suspect you are right in saying that it has something to do with ASAP. I will try to investigate this further and post an issue when I am able to reproduce the problem.
Since the problem probably lies somewhere within ASAP I will close this issue.
Sorry, I keep making very small posts. In pyvips you can create an image like this with:
The tile looks like this:
And can be opened like this (reading page 7 to keep the size reasonable):
To make: