-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ext/gd: imagewebp/imageavif/imagepng/imagejpeg stricter checks quality/speed. #14485
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
Conversation
91e9210
to
925dcc3
Compare
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.
Seems right
ext/gd/gd.c
Outdated
gdImageJpegCtx(im, ctx, (int) quality); | ||
break; | ||
#endif | ||
#ifdef HAVE_GD_WEBP | ||
case PHP_GDIMG_TYPE_WEBP: | ||
if (quality == -1) { | ||
if (quality < -1) { | ||
zend_argument_value_error(3, "must be at least -1"); |
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 "greater than or equal to" style is more commonly used with "at least" having only a few hits in the codebase.
ext/gd/gd.c
Outdated
zend_argument_value_error(3, "must be at least -1"); | ||
ctx->gd_free(ctx); | ||
RETURN_THROWS(); | ||
} else if (quality == -1) { |
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.
This "else if" branch is actually unnecessary:
php-src/ext/gd/libgd/gd_webp.c
Lines 120 to 122 in c7366cf
if (quality == -1) { | |
quality = 80; | |
} |
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.
yes saw that but was wondering if this is a "recent" addition was wondering why it is in place here then.
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.
It seems that the code previously used virtual functions so that might've been harder to see what the possible call targets are and therefore harder to see what's necessary and not. I'm fine with keeping this of course.
It's been in the library part since 2015: 00ba7e6
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.
I see. happy to remove anyway :)
925dcc3
to
d7b4eb9
Compare
@nielsdos I'd like to point out that the default quality of 80 that was dropped in this PR was only added to system gd from version 2.2.0, while we require 2.1.0 as minimum version, so this can theoretically break installations linking to system libgd 2.1 (no idea if any exists). |
Thanks for pointing this out. |
Definitively, 2.1.0 is 10 years+ old it seems. |
Then feel free to just bump it. |
No description provided.