Cms: imageSizeByStream return 0 for TIFF image - Index Asset S3 Image

Created on 1 Dec 2020  路  3Comments  路  Source: craftcms/cms

Description

I'm trying to index some TIFF assets from S3.
The problem is that the width and height always return 0.

From my understanding, the function imageSizeByStream (src/helpers/Image.php:210) should return the width and height of the stream but it only works for JPG, PNG, and GIF. The issue starts here: src/services/AssetIndexer.php:552 where the indexer tries to get the width and height of the image from a stream but get [0, 0] back.

I got ~125k TIFF to index, that's why I don't want to cache them locally.

So we may need to add support for other image formats inside imageSizeByStream (TIFF, WEBP, etc)

Steps to reproduce

  1. Connect to a S3 bucket
  2. Add some TIFF Images in the bucket
  3. Index them without cache (--cache-remote-images=0)
  4. The dimensions will be 0 and save as NULL inside the database.

Additional info

  • Craft version: 3.5.12.1
  • PHP version: 7.3.8
  • Database driver & version:
  • Plugins & versions:
    Craft CMS S3 - 1.2.11
bug minor

All 3 comments

Agree this should be possible, but not sure when we鈥檒l find the time to add support for it ourselves. Is this something you鈥檇 be able to PR?

@brandonkelly I will look into it with TIFF and WEBP in mind. Any other formats that should be supported with the kind IMAGE ?

@alexgilbertDG those would be a great start.

https://github.com/marc1706/fast-image-size/blob/master/lib/Type/TypeTif.php and https://github.com/marc1706/fast-image-size/blob/master/lib/Type/TypeWebp.php will probably be handy to figure out the bytes you would have to look at.

Was this page helpful?
0 / 5 - 0 ratings