-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
ext/gd: bug #80828 HEIF support. #14504
base: master
Are you sure you want to change the base?
Conversation
3f8df41
to
776b2b1
Compare
@@ -54,6 +55,7 @@ | |||
#define PHP_IMG_BMP 64 | |||
#define PHP_IMG_TGA 128 | |||
#define PHP_IMG_AVIF 256 | |||
#define PHP_IMG_HEIF 384 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this 384 instead of 512? I didn't understand this.
@@ -1408,6 +1418,11 @@ PHPAPI int php_getimagetype(php_stream *stream, const char *input, char *filetyp | |||
return IMAGE_FILETYPE_IFF; | |||
} else if (!memcmp(filetype, php_sig_ico, 4)) { | |||
return IMAGE_FILETYPE_ICO; | |||
} else if (!memcmp(filetype, php_sig_heifheic, 12) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment above indicates that only 4 bytes have been read, and a cursory glance shows me that indeed that is the case. So this memcmp won't do the job, I think you need to read additional bytes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, it s far from finished, e.g. gd does not support all HEIF formats (e.g. multi image format). imagecreatefromstring overall for this not gonna work for now (I wrote an email on internals).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I went here because I saw your email, I guess I should've waited a bit before reading the code.
Frankly, I'm not convinced that we should add HEIF support. Although that has obviously been merged into libgd, it has not been released yet. Furthermore, HEIF is only supported by Safari, and I presume that it will stay this way. Now, PHP is not only useful for Web applications, but still, it is mostly used on the Web. And there is JPEG XL, and surely next year there'll be the next big image format. And if we generally support HEIF, users will soon request Windows support for it, and I remember the PITA building AVIF on Windows, and apparently that is even broken yet. To be clear, I'm not strictly against adding HEIF support, but we should be aware that this may open up a can of worms, for limited usefulness (especially given that Safari appears in the process of supporting AVIF with new releases). And after all, Gif ought to be enough for anybody. ;) |
This would be especially useful for WordPress (or other PHP CMSs like Drupal) to be able to add HEIC image support (to enable converting uploaded HEICs to a web-safe format like JPEG). See my comment on the related ticket. |
Having support for HEIF would prevent issues like the following from arising: https://tracker.moodle.org/browse/MDL-79819 We have students uploading PDFs (containing HEIF images) and HEIF images into Moodle and TCPDF trips over its feet because it tries to call |
Note that HEIF/HEIC for |
No description provided.