SNAP gives TIFFopen errors displaying JP2 images if they have long filenames

In the browser I go to storage.cloud.google.com/gcp-public-data-sentinel-2/L2 and download a JPEG2000 band image

– e.g. from the url

https:// storage.cloud.google.com/gcp-public-data-sentinel-2/L2/tiles/32/T/ML/S2A_MSIL2A_20200710T102031_N0214_R065_T32TML_20200710T141844.SAFE/GRANULE/L2A_T32TML_A026374_20200710T102906/IMG_DATA/R10m/T32TML_20200710T102031_B08_10m.jp2

everything works fine even if the filename of the downloaded image is 174 characters long (thanks Google!): e.g.

L2_tiles_32_T_ML_S2A_MSIL2A_20200710T102031_N0214_R065_T32TML_20200710T141844.SAFE_GRANULE_L2A_T32TML_A026374_20200710T102906_IMG_DATA_R10m_T32TML_20200710T102031_B08_10m.jp2

In SNAP I can to import the same file – via the menu:

File | Import | Generic Formats | JPEG-2000

It shows up in the Product Explorer panel in which I can navigate to Bands and double click on band_1 to view it in the Image Window,

SNAP then give the following TIFFopen error messages and eventually freezes forcing me to kill it – see Screenshot here:
Snap-crash|690x367

Here’s a snap shot of Process Explorer just before the kill.

None of this happens when I shorten the filename beforehand to:
_T32TML_20200710T102031_B08_10m.jp2

My use-case is messed up if clients have to manually rename files.
Any chance of fix in a future version?

this is a limitation of windows. The path cannot be longer then 260 characters.
If you move the file into the root directory of C:\ then it you can probably open it, too.

There is a workaround to enable longer paths, but I never tried it:
How to Enable Long Path Support in Windows 10 (msftnext.com)

There is nothing we can do about.

Ah, now I see. This is an error when the intermediate Tiff file is read.
The Jpeg2000 reader converts it into temporary Tiff image.
I don’t know if this can be disabled or if the location where the file is stored can be modified.
It would be good if the filename would be shorter.

Maybe @oana_hogoiu has a hint?

Unfortunatelly not, for the moment.
I tested and the path lenght from .snap/var/cache (where the decompression in tiff tiles is done) is bigger than 450 characters.
There is the caching folder (.snap/var/cache) to which the original file name is added (171 characters), and then the tiles are also prefixed with the original file name (plus tile indexes), so even if we will double the original file name lenght (171 x 2) we will still depass 260 characters. So changing the location of tiles will not help, because the original file name length itself is too big.

Maybe it would be a good idea is the decompressed tiles are not prefixed with the original file name, but this have to be tested.

1 Like

Thanks Oana.
As an idea for the future. The files in the cache could have some short name and are then mapped to the original file name. Some how…
But ideally the original file name would not be so long.

1 Like

With shorter decompressed tiles names, I managed to open the band view:

We can go with this solution, I think. (meaning no longer use the original file name as prefix for the tiles, since they are already saved under a folder having the original file name)

Ticket SNAP-1436 created.

2 Likes