Skip to content
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

Error on files with both IPTC:Keywords and XMP-dc:Subject set to single value #37

Closed
z-jun opened this issue Mar 15, 2022 · 3 comments · Fixed by #39
Closed

Error on files with both IPTC:Keywords and XMP-dc:Subject set to single value #37

z-jun opened this issue Mar 15, 2022 · 3 comments · Fixed by #39

Comments

@z-jun
Copy link

z-jun commented Mar 15, 2022

PHPExif is unable to parse file with both tags set to single(parsed to string) value, at least with PHP8.

----> see issue at Lychee

[2022-03-03 02:50:12] production.ERROR: array_merge(): Argument https://github.com/LycheeOrg/Lychee/pull/1 must be of type array, string given {"exception":"[object] (TypeError(code: 0): array_merge(): Argument https://github.com/LycheeOrg/Lychee/pull/1 must be of type array, string given at /var/www/html/Lychee/vendor/lychee-org/php-exif/lib/PHPExif/Mapper/Exiftool.php:355)

Hot fix:

--- ./vendor/lychee-org/php-exif/lib/PHPExif/Mapper/Exiftool.php.old    2022-03-12 23:33:35.454873706 +0100
+++ ./vendor/lychee-org/php-exif/lib/PHPExif/Mapper/Exiftool.php        2022-03-12 23:32:41.507807585 +0100
@@ -349,10 +349,11 @@
                 // Merge sources of keywords
                 case self::KEYWORDS:
                 case self::SUBJECT:
+                    $xval = is_array( $value) ? $value : array( 0 => $value);
                     if (empty($mappedData[Exif::KEYWORDS])) {
-                        $mappedData[Exif::KEYWORDS] = $value;
+                        $mappedData[Exif::KEYWORDS] = $xval;
                     } else {
-                        $tmp = array_values(array_unique(array_merge($mappedData[Exif::KEYWORDS], $value)));
+                        $tmp = array_values(array_unique(array_merge($mappedData[Exif::KEYWORDS], $xval)));
                         $mappedData[Exif::KEYWORDS] = $tmp;
                     }

@kamil4
Copy link

kamil4 commented Apr 13, 2022

Thank you for the report and the fix! Would you mind posting a picture that triggers it? I want to check if this is something we need to fix for the native adapter as well...

@z-jun
Copy link
Author

z-jun commented Apr 13, 2022

Try this one or make from any photo by exiftool -Subject=bad -Keywords=bad some.jpg

ok

@kamil4
Copy link

kamil4 commented Apr 14, 2022

Thank you! This should now be fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants