Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image widht/height not properly detected for TIFs with multiple layers. #555

Open
lnielsen opened this issue Jan 18, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@lnielsen
Copy link
Member

Describe the bug

This code does not properly handle cases where an image file contains multiple images.

A test image is available on https://sandbox.zenodo.org/records/12129 with 5 images. The first being 4332 × 6804 the last being 135x212. The method detects the last image as the width/height, but we display the first.

Solution

For the test case the right width/height can found like this:

from wand.image import Image
with open(filename, "rb") as fp:
    with Image.ping(file=fp, format=ext) as img:
        imgseq = img.sequence[0]
        width = imgseq.width
        height = imgseq.height

Above should be tested on a suite of different images and types to ensure it works reliably.

Steps to Reproduce

Upload an image and check the IIIF manifest:
https://sandbox.zenodo.org/api/iiif/record:12129:2007-09-28_16-29-41.pyr.tif/info.json

Expected behavior

  • Extracts the width/height of the first image.
  • This requires reprocessing all images on Zenodo and probably other instances so we need to provide a script.

Additional context

% identify /Users/lnielsen/Downloads/2007-09-28_16-29-41.pyr.tif
2007-09-28_16-29-41.pyr.tif[0] TIFF 4332x6804 4332x6804+0+0 8-bit sRGB 5.19315MiB 0.010u 0:00.001
2007-09-28_16-29-41.pyr.tif[1] TIFF 2166x3402 2166x3402+0+0 8-bit sRGB 0.010u 0:00.001
2007-09-28_16-29-41.pyr.tif[2] TIFF 1083x1701 1083x1701+0+0 8-bit sRGB 0.010u 0:00.001
2007-09-28_16-29-41.pyr.tif[3] TIFF 541x850 541x850+0+0 8-bit sRGB 0.010u 0:00.001
2007-09-28_16-29-41.pyr.tif[4] TIFF 270x425 270x425+0+0 8-bit sRGB 0.010u 0:00.001
2007-09-28_16-29-41.pyr.tif[5] TIFF 135x212 135x212+0+0 8-bit sRGB 0.000u 0:00.001
@lnielsen lnielsen added the bug Something isn't working label Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant