xiaozhuai / imageinfo

Free Palestine🇵🇸🇵🇸🇵🇸Cross platform super fast single header c++ library to get image size and format without loading/decoding. Support avif, bmp, cur, dds, gif, hdr (pic), heic (heif), icns, ico, j2k, jp2, jpeg (jpg), jpx, ktx, png, psd, qoi, tga, tiff (tif), webp ...
MIT License
106 stars 26 forks source link

Error in reading width and height of heic image #16

Closed Charltsing closed 1 month ago

Charltsing commented 1 month ago

90.heic.zip 2

xiaozhuai commented 1 month ago

Confirmed. Will be fixed soon.

xiaozhuai commented 1 month ago

90.heic.zip

A super good heic sample file. This file contains multiple image item. And the primary item ispe box is not the first one in ipco box, that cause this issue. So we should find the correct ispe box by parsing pitm and ipma. Then we found the size is 4000x2252.

And more, it contains irot box, and irot = 3 which means the image is rotated 270 degrees clockwise. So the correct size is 2252x4000. And the image viewer in your screenshot show the size is 4000x2252 which is not correct.

The bug is fixed by https://github.com/xiaozhuai/imageinfo/commit/ab59f528705abe76e7da7ed7333596663e9af5b0

xiaozhuai commented 1 month ago

QQ_1722401592789

On macOS, it shows the size is 2252x4000.

Charltsing commented 1 month ago

你说的是正确的。我发截图的软件还没有更新ImageMagic的最新库。我和ImageMagic拉扯了好几天他才搞明白heic的图像方向。 你比dlemstra明白多了。

另外,考虑图像方向问题,我觉得ImageInfo是否考虑读取Exif,在输出中增加方向的数据。 有些图像靠Exif输出方向。

例如,在90.heic这个图像中,原始宽高是4000x2252,图像旋转之后的宽高是2252x4000。 所以,我们需要BaseWidth、Width、Rotation direction三个输出。

这个也不急。

xiaozhuai commented 1 month ago

我和ImageMagic拉扯了好几天他才搞明白heic的图像方向。

公开的关于heif封装格式的文档确实少的可怜,而且缺少很多细节。我也是只能看代码才能理解它的设计。

另外,考虑图像方向问题,我觉得ImageInfo是否考虑读取Exif,在输出中增加方向的数据。 有些图像靠Exif输出方向。

我思考一下这个问题,由于有些格式包含多个entry,例如icns和ico/cur等,需要为主entry和每个entry都添加rotation, base_width, base_height,这会搞的很复杂。可能并不符合这个库的设计。

Charltsing commented 1 month ago

暂时先读Exif就可以了,它的信息很重要。

其它不支持exif的图像,估计也没啥人关心方向

Direction90.zip

xiaozhuai commented 1 month ago

暂时先读Exif就可以了,它的信息很重要。

我先修复包含exif的jpg图像吧

xiaozhuai commented 1 month ago

Direction90.zip

Fixed by https://github.com/xiaozhuai/imageinfo/commit/206a53a4c61763a992cc5a9c87d4fbafe5bcd315

Charltsing commented 1 month ago

HEIF容器