-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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/exif: Minor refactoring of exif_thumbnail() #16111
Conversation
ext/exif/exif.c
Outdated
ZVAL_STRINGL(return_value, ImageInfo.Thumbnail.data, ImageInfo.Thumbnail.size); | ||
if (arg_c >= 3) { | ||
RETVAL_STRINGL(ImageInfo.Thumbnail.data, ImageInfo.Thumbnail.size); | ||
if (z_height) { |
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.
Fun fact: this means that if you pass a $width argument but not the $height argument, that the $width isn't even filled in.
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.
Right, I hadn't even realised this.
This is pretty suboptimal :|
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.
Okay, made some changes so that one can just pass $width
4546b87
to
2a126aa
Compare
ext/exif/exif.c
Outdated
} | ||
if (z_height) { | ||
if (!ImageInfo.Thumbnail.height) { | ||
if (!exif_scan_thumbnail(&ImageInfo)) { |
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.
Now you'll be scanning twice in case of a zero height.
I also don't like the duplication.
I'd just do (untested):
if ((z_width || z_height) && (!ImageInfo.Thumbnail.width || !ImageInfo.Thumbnail.height)) {
if (!exif_scan_thumbnail(&ImageInfo)) {
ImageInfo.Thumbnail.width = ImageInfo.Thumbnail.height = 0;
}
}
ext/exif/exif.c
Outdated
ZEND_TRY_ASSIGN_REF_LONG(z_height, ImageInfo.Thumbnail.height); | ||
} | ||
if (arg_c >= 4) { | ||
if (z_imagetype) { |
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.
bizarre indentation of the {
No description provided.