php / php-src

The PHP Interpreter
https://www.php.net
Other
38.2k stars 7.75k forks source link

AVIF image errors #13919

Closed ve3 closed 2 weeks ago

ve3 commented 7 months ago

Description

The following code:

<?php
$image = imagecreatefromavif('image.avif');

Resulted in this output: There are different errors. If you downloaded image from https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/Apple/multilayer_examples where file name is animals_00_multilayer_a1lx.avif
The result on Windows will be:

Warning: imagecreatefromavif(): avif error - Could not parse image: No AV1 items found

The result on Linux will be:

Notice: imagecreatefromavif(): Image's color profile is not sRGB

If you downloaded image file name animals_00_multilayer_grid_a1lx.avif
The result on Windows will be:

Warning: imagecreatefromavif(): avif error - Could not parse image: Invalid image grid

The result on Linux will be:

Notice: imagecreatefromavif(): Image's color profile is not sRGB

If you downloaded image file name animals_00_singlelayer.avif
The result on Windows will be:

Notice: imagecreatefromavif(): Image's color profile is not sRGB

The result on Linux will be:

Notice: imagecreatefromavif(): Image's color profile is not sRGB

But I expected this output instead:

\GdImage

PHP Version

PHP 8.3.1, PHP 8.3.4

Operating System

Windows 11 x64, Debian (based on Docker php:8.3-apache).

nielsdos commented 7 months ago

This is because the Windows builds ship an older version of libavif which does not work with these files. We need to look into upgrading the libavif version we ship with the Windows builds.

ve3 commented 7 months ago

There is different error on Debian (Docker php:8.3-apache). Updated on the post.

nielsdos commented 7 months ago

There is different error on Debian (Docker php:8.3-apache). Updated on the post.

The notice is non-fatal. The transfer characteristics are sRGB for the first test tile, but the color primaries are SMPTE432. Looking at the primaries in the CIE chromaticity diagram for SMPTE432 (https://en.wikipedia.org/wiki/DCI-P3#/media/File:CIE1931xy_gamut_comparison_of_sRGB_P3_Rec2020.svg) shows that the don't have the same primaries as sRGB. So the image isn't sRGB indeed. The notice is therefore expected.

cmb69 commented 2 months ago

https://github.com/winlibs/libavif/pull/3 would fix this issue.