xperseguers / t3ext-extractor

TYPO3 Extension extractor
https://extensions.typo3.org/extension/extractor
GNU General Public License v2.0
14 stars 23 forks source link

inaccurate data type for iso_speed #45

Closed davidzach closed 2 years ago

davidzach commented 2 years ago

Dear Xavier,

I have encountered a small problem when uploading images with multiple ISOSpeedRatings.

In this case the value becomes a string and cannot be written to the database anymore, because this is an integer field.

As a result the following error occurs:

Core: Exception handler (WEB): Uncaught TYPO3 Exception: An exception occurred while executing 'INSERT INTO sys_file_metadata (file, pid, crdate, tstamp, cruser_id, l10n_diffsource, width, height, color_space, unit, camera_make, camera_model, shutter_speed, focal_length, iso_speed, aperture) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [147, 0, 1641551837, 1641551837, 5, "", 2048, 1152, "RGB", "px", "SAMSUNG", "SM-T230", "66\/65536", 2.79, "50, 0", 2.6000000000000001]: Data truncated for column 'iso_speed' at row 1 | Doctrine\DBAL\Exception\DriverException thrown in file /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php in line 128.

As a small Workaround I have adapted the file: extractor/Classes/Service/Extraction/AbstractExtractionService.php

$value = isset($value[$key]) ? $value[$key] : null;

The line above becomes:

if ($key === 'ISOSpeedRatings') {
    $value = isset($value[$key][0]) ? $value[$key][0] : 0;
} else {
    $value = isset($value[$key]) ? $value[$key] : null;
}

Can we talk briefly about whether that is a good solution. Then I can provide a merge request.

Best regards David

xperseguers commented 2 years ago

So you mean changing this line: https://github.com/xperseguers/t3ext-extractor/blob/master/Classes/Service/Extraction/AbstractExtractionService.php#L335

I miss the information on how you are currently extracting metadata, is it with plain PHP or with some external tool?

If with plain PHP, then I'd say it would be better to adapt https://github.com/xperseguers/t3ext-extractor/blob/master/Classes/Service/Extraction/PhpMetadataExtraction.php instead.

If this is with some external tool, please specify which one, to see if I can reproduce (could be related to some version of the external tool).

Anyway, I'd like to better understood the actual value you have in your EXIF info and be sure to fix it the best way instead of possibly "hacking around" as this problem may possibly get better solved. Maybe you could post a sample picture to be able to reproduce this problem?

davidzach commented 2 years ago

Dear Xavier,

Thank you very much for your feedback.

In the meantime, I have provided an image for testing purposes.

See: https://1drv.ms/u/s!AOFT_JOvydIVg9UZ

We'll talk again after you reproduce the error.

Best regards David

davidzach commented 2 years ago

In summary, the extension works. The problem is more with the images.

What could be done here is to prevent an error during the upload, even if an image provides incorrect information.