Skip to content

AVIF support for getimagesize() and imagecreatefromstring() #7091

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

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
729d496
Initial commit before rebase
morsssss May 5, 2021
9bd126f
Incremental commit
morsssss May 7, 2021
dc51fb1
Incremental commit
morsssss May 10, 2021
3e38e9a
Change gd includes to quotes instead of angle brackets
morsssss May 11, 2021
e279fe0
Fix includes
morsssss May 21, 2021
50db465
Add test script and test image
morsssss May 21, 2021
93dd902
Fix IMAGETYPE_AVIF support
cmb69 May 22, 2021
cdcebf6
Fix failing test case
cmb69 May 22, 2021
67cc00c
Initial commit before rebase
morsssss May 5, 2021
76680fd
Incremental commit
morsssss May 7, 2021
7e08fe6
Change gd includes to quotes instead of angle brackets
morsssss May 11, 2021
452ebce
Fix includes
morsssss May 21, 2021
504c50f
Fix IMAGETYPE_AVIF support
cmb69 May 22, 2021
cae634c
Remove AVIF tests from travis and azure; add to cirrus
morsssss May 24, 2021
0f35858
Remove avif from a few more spots in test configs
morsssss May 24, 2021
580b3ad
Removed libavif-dev package from azure
morsssss May 24, 2021
cb46c53
Install libavif in freebsd
morsssss May 24, 2021
f88c2b1
Fixes from code review
morsssss May 25, 2021
5644814
Newline between test output and expected output
morsssss May 26, 2021
2c44c20
AVIF support in getimagesize()
morsssss Jun 2, 2021
7601270
Rename php_little2bigendian() => php_ntohl()
morsssss Jun 2, 2021
6a58495
Remove unnecessary comment
morsssss Jun 3, 2021
1d0d4a8
Working support for AVIF in imagecreatefromstring()
morsssss Jun 5, 2021
06d2a09
Move php_gd_image_reader and php_is_image_avif()
morsssss Jun 6, 2021
2e71d61
Add tests and test images
morsssss Jun 10, 2021
86a5aa1
data => ZSTR_VAL(data)
morsssss Jun 10, 2021
c523014
Removed unnecessary spacing
morsssss Jun 10, 2021
66f731c
Update expected test results
morsssss Jun 10, 2021
80ac6b0
fix for webp detection
morsssss Jun 10, 2021
8755426
correct number of expected array elements in test results
morsssss Jun 10, 2021
7a715ec
Specify type in php_ntohl() param
morsssss Jun 10, 2021
7e64a09
Fully initialize each php_gd_image_reader
morsssss Jun 14, 2021
46fa3db
Fix indents
morsssss Jun 16, 2021
79bab8f
Fixing more indents
morsssss Jun 17, 2021
d9931a4
Move up checking for AVIF
morsssss Jun 17, 2021
a13e98d
Use memory stream instead of php_image_reader
morsssss Jul 1, 2021
505e4b5
Merge branch 'master' into getimagetype
morsssss Jul 1, 2021
2ff585b
Improvements to streams
morsssss Jul 4, 2021
dc8e549
really handling streams properly this time
morsssss Jul 4, 2021
85d2306
More compact php_handle_avif()
morsssss Jul 5, 2021
7689889
Use bool, not int
morsssss Jul 5, 2021
54907d0
Code review style changes
morsssss Jul 5, 2021
11bef5c
Add indents
morsssss Jul 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improvements to streams
  • Loading branch information
morsssss committed Jul 4, 2021
commit 2ff585beb65506a54dfbf21fd6f6c964520c5ec7
8 changes: 6 additions & 2 deletions ext/gd/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1499,8 +1499,12 @@ static int _php_image_type (zend_string *data)

php_stream *image_stream = php_stream_memory_open(TEMP_STREAM_READONLY, data);

if (php_is_image_avif(image_stream)) {
return PHP_GDIMG_TYPE_AVIF;
if (image_stream != NULL) {
if (php_is_image_avif(image_stream)) {
return PHP_GDIMG_TYPE_AVIF;
}

php_stream_close(image_stream);
}

gdIOCtx *io_ctx;
Expand Down
4 changes: 4 additions & 0 deletions ext/standard/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,10 @@ int php_is_image_avif(php_stream * stream) {
uint32_t header_size_reversed, header_size, i;
char box_type[4], brand[4];

if (stream == NULL) {
return 0;
}

if (php_stream_read(stream, (char *) &header_size_reversed, 4) != 4) {
return 0;
}
Expand Down