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

Finish AVIF support in getimagesize() #7711

Closed
wants to merge 4 commits into from
Closed

Conversation

y-guyon
Copy link
Contributor

@y-guyon y-guyon commented Dec 3, 2021

Currently getimagesize() identifies AVIF files but does not fill the image properties.
This patch fixes this issue by copy-pasting libavifinfo's 700-line C source and header, called from getimagesize().
libavifinfo parses a stream quickly and partially, without dynamic memory allocation.
See the bug #80828, the internals@ mailing list discussion #116543 and the GitHub discussion #5127.

The total bin folder size goes from 117950251 bytes to 118036716, which represents an increase of 0.0733%.

Tests pass. Compilation was only tried with default and enable-debug flags on Linux for now.

See #80828 and the internals@ mailing list discussion at
https://externals.io/message/116543

Use libavifinfo's AvifInfoGetFeaturesStream() in php_handle_avif() to
get the width, height, bit depth and channel count from an AVIF
payload. Implement stream reading/skipping functions and data struct.
Use libavifinfo's AvifInfoIdentifyStream() in php_is_image_avif().

Update the expected features read from "test1pix.avif" in
getimagesize.phpt.
Copy link
Contributor

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! I'm generally in favor of bundling libavifinfo (at least as long as it is not widely available), and I'm not really concerned about the size. Others may object, though, and we may consider to make its inclusion optional (--with-libavifinfo). Let's see.

Anyhow, please fix the Windows build (comment below), and consider to restore the old format of config.m4 to avoid potential merge conflicts; having an overlong line there appears not to be a problem). I also wonder why the directory name is image_avif instead of libavifinfo; I'd prefer the latter.

ext/standard/config.w32 Outdated Show resolved Hide resolved
Fix Windows build.
Revert config.m4 formatting to the previous one.
@y-guyon
Copy link
Contributor Author

y-guyon commented Dec 7, 2021

Thanks for the quick review.

I'm generally in favor of bundling libavifinfo (at least as long as it is not widely available)

I do not plan to release libavifinfo binaries for now. It is meant to be built by users or copy-pasted.

I also wonder why the directory name is image_avif instead of libavifinfo; I'd prefer the latter.

I used the name image_avif because it is solely used by image.c but libavifinfo makes sense too. Done.

@cmb69
Copy link
Contributor

cmb69 commented Dec 7, 2021

Thanks for the update!

I do not plan to release libavifinfo binaries for now. It is meant to be built by users or copy-pasted.

I wasn't referring to binaries, but rather a stand-alone library which may be distributed by third-parties (e.g. Linux distro managers). Having it as system library appears to be beneficial. But anyway, keeping it bundled shouldn't be a problem either (we do that with some other libraries as well).

@cmb69
Copy link
Contributor

cmb69 commented Dec 7, 2021

The AppVeyor failure looks unrelated; the Azure Pipeline failures definitely are.

@y-guyon
Copy link
Contributor Author

y-guyon commented Dec 7, 2021

How can I relaunch the checks? Should I rebase?

@cmb69
Copy link
Contributor

cmb69 commented Dec 7, 2021

How can I relaunch the checks? Should I rebase?

No need to. I re-triggered the AppVeyor build just now; the Azure builds are already failing for ~2 days, so no need to re-run them until the issue is resolved.

@andypost
Copy link
Contributor

++ to add it to standard codebase as distro-builders can vary it as GD

@cmb69
Copy link
Contributor

cmb69 commented Dec 10, 2021

If this gets merged, there needs to be an entry added in README.REDIST.BINS regarding the libavifinfo license.

Move license text from README.md to original files LICENSE and PATENTS.
@y-guyon
Copy link
Contributor Author

y-guyon commented Dec 10, 2021

If this gets merged, there needs to be an entry added in README.REDIST.BINS regarding the libavifinfo license.

Done.

@y-guyon
Copy link
Contributor Author

y-guyon commented Dec 15, 2021

Feel free to ask here if there is anything else I can do to help move this forward.

Copy link
Contributor

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://externals.io/message/116543#116608, I think we should merge this, but please have a look at my CS nits.

README.REDIST.BINS Show resolved Hide resolved
ext/standard/image.c Outdated Show resolved Hide resolved
ext/standard/image.c Outdated Show resolved Hide resolved
ext/standard/image.c Outdated Show resolved Hide resolved
Copy link
Contributor

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@cmb69 cmb69 closed this in 38460c2 Dec 15, 2021
@ophian
Copy link

ophian commented Jan 16, 2022

Thanks for this! I am excited to run (and finish) Serendipity Styx with it.
It is now in PHP 8.2.0alpha1, which is estimated to release at the end of 2022.
There is no way to use it earlier, is it?

@cmb69
Copy link
Contributor

cmb69 commented Jan 16, 2022

@ophian, you can checkout/download the latest HEAD of php-src, and build yourself.

@ophian
Copy link

ophian commented Jan 16, 2022

well yes... ;-) But I cannot say this my users though!

@cmb69
Copy link
Contributor

cmb69 commented Jan 16, 2022

But I cannot say this my users though!

Okay, I see. They will have to wait for PHP 8.2.0, which is supposed to be released at the end of 2022. :|

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants