Skip to content

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Sep 28, 2024

No description provided.

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) {
Copy link
Member

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.

Copy link
Member Author

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 :|

Copy link
Member Author

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

@Girgias Girgias changed the title ext/exif: Minor refactoring of exif_read_data() ext/exif: Minor refactoring of exif_thumbnail() Sep 28, 2024
ext/exif/exif.c Outdated
}
if (z_height) {
if (!ImageInfo.Thumbnail.height) {
if (!exif_scan_thumbnail(&ImageInfo)) {
Copy link
Member

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) {
Copy link
Member

Choose a reason for hiding this comment

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

bizarre indentation of the {

@Girgias Girgias merged commit 291eef2 into php:master Sep 29, 2024
9 of 10 checks passed
@Girgias Girgias deleted the exif-argnum branch September 29, 2024 14:57
jorgsowa pushed a commit to jorgsowa/php-src that referenced this pull request Oct 1, 2024
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.

2 participants