serverless-iiif icon indicating copy to clipboard operation
serverless-iiif copied to clipboard

New errors in image tiles

Open cweinard opened this issue 4 months ago • 4 comments

Hello, We've got pyramidal tiffs on S3, with custom S3 metadata for height, width and others.

These were working well with Openseadragon. Sometime in the last month or so, they stopped working. The zoomed-out view is blank, and only zoomed-in views work.

Web inspector shows some tiles returning a 500 error. When you look at tiles with a 500 error, you see "Error: Input buffer has corrupt header: tiff2vips: TIFF does not contain page 2"

I'm doing some testing, and finding that the same source tiffs, uploaded to the source bucket without S3 custom metadata, work fine. All tiles resolve for those files.

It seems like something changed in the function to cause the problem. (Did the JP2 layer change? Could the issue be fixed by changing the sharp layer env variable to INTERNAL?)

Suggestions welcome--Thanks!

cweinard avatar Aug 18 '25 15:08 cweinard

Thanks for reporting this. I'm out until Monday the 25th, but if you know how many pages your TIFF has (you can use tiffinfo or viosheader or GraphicsMagick to find out), you can set the pages metadata property to override the dimension function's default page calculation.

mbklein avatar Aug 18 '25 15:08 mbklein

I think we're experiencing the same issue. I used tiffinfo on one of the images that causing trouble. Here's the output. Five pages(?). The image is 9818 x 13420, which is probably larger than average for us.

=== TIFF directory 0 ===
TIFF Directory at offset 0x7f37f2e (133398318)
  Image Width: 13420 Image Length: 9818
  Tile Width: 1024 Tile Length: 1024
  Resolution: 400, 400 pixels/inch
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: JPEG
  Photometric Interpretation: RGB color
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 3
  Planar Configuration: single image plane
  JPEG Tables: (289 bytes)

=== TIFF directory 1 ===
TIFF Directory at offset 0x9a0b96a (161528170)
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 6710 Image Length: 4909
  Tile Width: 1024 Tile Length: 1024
  Resolution: 400, 400 pixels/inch
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: RGB color
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 3
  Planar Configuration: single image plane
  JPEG Tables: (289 bytes)

=== TIFF directory 2 ===
TIFF Directory at offset 0xa0967a4 (168388516)
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 3355 Image Length: 2454
  Tile Width: 1024 Tile Length: 1024
  Resolution: 400, 400 pixels/inch
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: RGB color
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 3
  Planar Configuration: single image plane
  JPEG Tables: (289 bytes)

=== TIFF directory 3 ===
TIFF Directory at offset 0xa245708 (170153736)
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 1677 Image Length: 1227
  Tile Width: 1024 Tile Length: 1024
  Resolution: 400, 400 pixels/inch
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: RGB color
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 3
  Planar Configuration: single image plane
  JPEG Tables: (289 bytes)

=== TIFF directory 4 ===
TIFF Directory at offset 0xa2b4a76 (170609270)
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 838 Image Length: 613
  Tile Width: 1024 Tile Length: 1024
  Resolution: 400, 400 pixels/inch
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: RGB color
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 3
  Planar Configuration: single image plane
  JPEG Tables: (289 bytes)

eliotjordan avatar Aug 18 '25 21:08 eliotjordan

Adding the pages metadata seems to solved the issue.

eliotjordan avatar Aug 18 '25 21:08 eliotjordan

That's it. In the absence of explicit pages metadata, the app assumes pages reduce in size by half until at least one dimension is <256px.

mbklein avatar Aug 22 '25 10:08 mbklein