strukturag / libheif

libheif is an HEIF and AVIF file format decoder and encoder.
Other
1.77k stars 306 forks source link

Black bars on Sony HIF thumbnails #1406

Open teletypo opened 1 day ago

teletypo commented 1 day ago

Here's a HIF-image of a Sony ILX-LR1: 20241120-214155-cam0-000-000004-0.zip. It's captured at full 61MP with a 3:2 aspect ratio (the only way to get the full 61MP). The HIF pixel size is 9504x6336.

heif_info shows that there's 3 thumbnails embedded:

MIME type: image/heic
main brand: heix
compatible brands: mif1, heix, miaf, MiHA, jpeg, SHIF

image: 9504x6336 (id=10), primary
  colorspace: YCbCr, 4:2:2
  bit depth: 10
  thumbnail: 1616x1080
  thumbnail: 320x212
  thumbnail: 160x120
  color profile: nclx
  alpha channel: no 
  depth channel: no
metadata:
  Exif: 94208 bytes
  XMP: 57344 bytes
transformations:
  angle (ccw): 0
region annotations:
  none
properties:

Now I don't know why Sony decided to create thumbnails in different aspect ratios, but it seems they also decided to just add black bar(s!), probably to make up for the mismatch:

heif-thumbnailer 20241120-214155-cam0-000-000004-0.HIF 20241120-214155-cam0-000-000004-0-heif-thumbnailer.jpg

20241120-214155-cam0-000-000004-0-heif-thumbnailer

I see the same in dolphin, KDE's file manager:

image

But when I invest 99 cents to install the HEVC Video Extensions in the windows app store on a windows 10 machine, I get proper thumbnails in windows:

windowsexplorer

Now, it could be that windows is bypassing the problem by just using thumbnail 1 instead. But the thumbnail shown above in windows explorer are about 245x162 pixels, so windows might have gotten those from thumbnail 2.

So...

Thanks!

bradh commented 1 day ago

Note for further investigation: maybe we need clap for the thumbnail.

farindk commented 1 day ago

I analyzed the file. It contains three thumbnails:

None of the images has a clap.

Thus, the HEIF file is wrong. The ispe does not match the encoded image size. Probably, the Windows decoder crops the image to the ispe size, but it should not do so without a clap.

Image 11: image

Image 12: image

Image 13: image

L4cache commented 5 hours ago

I have a bad news for you, HEVC Extension is free (preinstalled) in Windows 11...

teletypo commented 4 hours ago

Thanks @L4cache, I will ask Microsoft for a refund ;)

@bradh and @farindk, I have asked Sony to take a look at this and hope that we can soon report back with something. Thank you for your impressively fast responses!

farindk commented 3 hours ago

If it is an error that affects many images, and I guess that the camera firmware is not easy to upgrade, we might consider to add an option to the thumbnailer to crop the images to the ispe size to offer a workaround to faulty input images.