xperseguers / t3ext-extractor

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

Metadata can't be extracted from files with metadata "aperture" with string "Inf" #77

Closed sypets closed 7 months ago

sypets commented 10 months ago

exiftool output

`$exiftool MG_9719-600x400.jpg | grep -i aperture

` output:

Aperture Value                  : Inf
Aperture                        : Inf

open questions

Is this value correct for aperture? Unfortunately I have not found a good authoritative source for exif metadata.

Possibly, the extensions should do a sanity check if value has correct datatype / allowed values (e.g. is numeric) or TYPO3 should do it.

Logfile

UPDATE `sys_file_metadata` SET `pid` = ?, `tstamp` = ?, `crdate` = ?, `cruser_id` = ?, `sys_language_uid` = ?, `l10n_parent` = ?, `l10n_diffsource` = ?, `t3ver_oid` = ?, `t3ver_wsid` = ?, `t3ver_state` = ?, `t3ver_stage` = ?, `t3ver_count` = ?, `t3ver_tstamp` = ?, `t3ver_move_id` = ?, `t3_origuid` = ?, `file` = ?, `title` = ?, `width` = ?, `height` = ?, `description` = ?, `alternative` = ?, `categories` = ?, `visible` = ?, `status` = ?, `keywords` = ?, `caption` = ?, `creator_tool` = ?, `download_name` = ?, `creator` = ?, `publisher` = ?, `source` = ?, `location_country` = ?, `location_region` = ?, `location_city` = ?, `latitude` = ?, `longitude` = ?, `ranking` = ?, `content_creation_date` = ?, `content_modification_date` = ?, `note` = ?, `unit` = ?, `duration` = ?, `color_space` = ?, `pages` = ?, `language` = ?, `fe_groups` = ?, `copyright` = ?, `l10n_state` = ?, `camera_make` = ?, `camera_model` = ?, `camera_lens` = ?, `shutter_speed` = ?, `focal_length` = ?, `exposure_bias` = ?, `white_balance_mode` = ?, `iso_speed` = ?, `aperture` = ?, `flash` = ?, `altitude` = ? WHERE `uid` = ?' 
with params 
[0, 1702119979, 1625431619, 190, 0, 0, \"\", 0, 0, 0, 0, 0, 0, 0, 0, 278311, null, 600, 400, null, null, 0, 1, \"\", null, null, \"Adobe Photoshop CS6 (Windows)\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"0.00000000000000\", \"0.00000000000000\", 0, 1476440870, 1478114393, null, \"\", 0, \"RGB\", 0, \"\", null, null, null, \"Canon\", \"Canon EOS 600D\", \"\", \"1\\/1250\", 78.6, \"\", \"Auto\", 0, \"Inf\", 16, 0, 274300]:

Incorrect double value: 'Inf' for column `typo3`.`sys_file_metadata`.`aperture` at row 1 

SQL DB Schema (TYPO3)

sys_file_metadata

aperture | double | NO | | 0 | |

xperseguers commented 10 months ago

When I use exiv2 instead of exiftool, I get no aperture value at all (empty).

When I open the file in Photoshop and show the raw data, I see this:

<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 9.1-c001 79.1462899777, 2023/06/25-23:57:14        ">
   <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
      <rdf:Description rdf:about=""
            xmlns:xmp="http://ns.adobe.com/xap/1.0/"
            xmlns:aux="http://ns.adobe.com/exif/1.0/aux/"
            xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"
            xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"
            xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#"
            xmlns:dc="http://purl.org/dc/elements/1.1/"
            xmlns:tiff="http://ns.adobe.com/tiff/1.0/"
            xmlns:exif="http://ns.adobe.com/exif/1.0/">
         <xmp:Rating>0</xmp:Rating>
         <xmp:ModifyDate>2016-11-02T20:19:53+01:00</xmp:ModifyDate>
         <xmp:CreateDate>2016-10-14T12:27:50</xmp:CreateDate>
         <xmp:MetadataDate>2016-11-02T20:19:53+01:00</xmp:MetadataDate>
         <xmp:CreatorTool>Adobe Photoshop CS6 (Windows)</xmp:CreatorTool>
         <aux:SerialNumber>193066081036</aux:SerialNumber>
         <aux:LensSerialNumber>0000000000</aux:LensSerialNumber>
         <aux:ImageNumber>0</aux:ImageNumber>
         <aux:FlashCompensation>0/1</aux:FlashCompensation>
         <aux:Firmware>1.0.2</aux:Firmware>
         <photoshop:DateCreated>2016-10-14T12:27:50.051</photoshop:DateCreated>
         <photoshop:LegacyIPTCDigest>A131B213AF678EAEA4799E62A6CB2F6B</photoshop:LegacyIPTCDigest>
         <photoshop:ColorMode>3</photoshop:ColorMode>
         <photoshop:ICCProfile>Adobe RGB (1998)</photoshop:ICCProfile>
         <photoshop:DocumentAncestors>
            <rdf:Bag>
               <rdf:li>0A5E203B7520E1BDA3B8E707255064E5</rdf:li>
            </rdf:Bag>
         </photoshop:DocumentAncestors>
         <xmpMM:DocumentID>0A5E203B7520E1BDA3B8E707255064E5</xmpMM:DocumentID>
         <xmpMM:InstanceID>xmp.iid:5704885131A1E6118297B44227F13E8E</xmpMM:InstanceID>
         <xmpMM:OriginalDocumentID>0A5E203B7520E1BDA3B8E707255064E5</xmpMM:OriginalDocumentID>
         <xmpMM:History>
            <rdf:Seq>
               <rdf:li rdf:parseType="Resource">
                  <stEvt:action>saved</stEvt:action>
                  <stEvt:instanceID>xmp.iid:5504885131A1E6118297B44227F13E8E</stEvt:instanceID>
                  <stEvt:when>2016-11-02T20:19:47+01:00</stEvt:when>
                  <stEvt:softwareAgent>Adobe Photoshop CS6 (Windows)</stEvt:softwareAgent>
                  <stEvt:changed>/</stEvt:changed>
               </rdf:li>
               <rdf:li rdf:parseType="Resource">
                  <stEvt:action>saved</stEvt:action>
                  <stEvt:instanceID>xmp.iid:5704885131A1E6118297B44227F13E8E</stEvt:instanceID>
                  <stEvt:when>2016-11-02T20:19:53+01:00</stEvt:when>
                  <stEvt:softwareAgent>Adobe Photoshop CS6 (Windows)</stEvt:softwareAgent>
                  <stEvt:changed>/</stEvt:changed>
               </rdf:li>
            </rdf:Seq>
         </xmpMM:History>
         <dc:format>image/jpeg</dc:format>
         <tiff:ImageWidth>3456</tiff:ImageWidth>
         <tiff:ImageLength>5184</tiff:ImageLength>
         <tiff:BitsPerSample>
            <rdf:Seq>
               <rdf:li>8</rdf:li>
               <rdf:li>8</rdf:li>
               <rdf:li>8</rdf:li>
            </rdf:Seq>
         </tiff:BitsPerSample>
         <tiff:PhotometricInterpretation>2</tiff:PhotometricInterpretation>
         <tiff:Orientation>1</tiff:Orientation>
         <tiff:SamplesPerPixel>3</tiff:SamplesPerPixel>
         <tiff:YCbCrPositioning>2</tiff:YCbCrPositioning>
         <tiff:XResolution>72/1</tiff:XResolution>
         <tiff:YResolution>72/1</tiff:YResolution>
         <tiff:ResolutionUnit>2</tiff:ResolutionUnit>
         <tiff:WhitePoint>
            <rdf:Seq>
               <rdf:li>313/1000</rdf:li>
               <rdf:li>329/1000</rdf:li>
            </rdf:Seq>
         </tiff:WhitePoint>
         <tiff:PrimaryChromaticities>
            <rdf:Seq>
               <rdf:li>64/100</rdf:li>
               <rdf:li>33/100</rdf:li>
               <rdf:li>21/100</rdf:li>
               <rdf:li>71/100</rdf:li>
               <rdf:li>15/100</rdf:li>
               <rdf:li>6/100</rdf:li>
            </rdf:Seq>
         </tiff:PrimaryChromaticities>
         <tiff:YCbCrCoefficients>
            <rdf:Seq>
               <rdf:li>299/1000</rdf:li>
               <rdf:li>587/1000</rdf:li>
               <rdf:li>114/1000</rdf:li>
            </rdf:Seq>
         </tiff:YCbCrCoefficients>
         <tiff:Make>Canon</tiff:Make>
         <tiff:Model>Canon EOS 600D</tiff:Model>
         <exif:ExifVersion>0230</exif:ExifVersion>
         <exif:FlashpixVersion>0100</exif:FlashpixVersion>
         <exif:ColorSpace>65535</exif:ColorSpace>
         <exif:PixelXDimension>1333</exif:PixelXDimension>
         <exif:PixelYDimension>2000</exif:PixelYDimension>
         <exif:DateTimeOriginal>2016-10-14T12:27:50</exif:DateTimeOriginal>
         <exif:ExposureTime>1/1250</exif:ExposureTime>
         <exif:FNumber>0/1</exif:FNumber>
         <exif:ExposureProgram>1</exif:ExposureProgram>
         <exif:ISOSpeedRatings>
            <rdf:Seq>
               <rdf:li>4000</rdf:li>
            </rdf:Seq>
         </exif:ISOSpeedRatings>
         <exif:ShutterSpeedValue>679936/65536</exif:ShutterSpeedValue>
         <exif:ApertureValue>-2147483648/1000000</exif:ApertureValue>
         <exif:ExposureBiasValue>0/1</exif:ExposureBiasValue>
         <exif:MeteringMode>5</exif:MeteringMode>
         <exif:Flash rdf:parseType="Resource">
            <exif:Fired>False</exif:Fired>
            <exif:Return>0</exif:Return>
            <exif:Mode>2</exif:Mode>
            <exif:Function>False</exif:Function>
            <exif:RedEyeMode>False</exif:RedEyeMode>
         </exif:Flash>
         <exif:FocalLength>50/1</exif:FocalLength>
         <exif:FocalPlaneXResolution>5184000/905</exif:FocalPlaneXResolution>
         <exif:FocalPlaneYResolution>3456000/595</exif:FocalPlaneYResolution>
         <exif:FocalPlaneResolutionUnit>2</exif:FocalPlaneResolutionUnit>
         <exif:CustomRendered>0</exif:CustomRendered>
         <exif:ExposureMode>1</exif:ExposureMode>
         <exif:WhiteBalance>0</exif:WhiteBalance>
         <exif:SceneCaptureType>0</exif:SceneCaptureType>
         <exif:SubSecTime>51</exif:SubSecTime>
         <exif:SubSecTimeOriginal>51</exif:SubSecTimeOriginal>
         <exif:SubSecTimeDigitized>51</exif:SubSecTimeDigitized>
         <exif:SerialNumber>193066081036</exif:SerialNumber>
         <exif:LensInfo>
            <rdf:Seq>
               <rdf:li>0/0</rdf:li>
            </rdf:Seq>
         </exif:LensInfo>
         <exif:LensSerialNumber>0000000000</exif:LensSerialNumber>
         <exif:SensitivityType>2</exif:SensitivityType>
         <exif:RecommendedExposureIndex>4000</exif:RecommendedExposureIndex>
      </rdf:Description>
   </rdf:RDF>
</x:xmpmeta>

Thus in that case, the aperture is:

<exif:ApertureValue>-2147483648/1000000</exif:ApertureValue>

and -2147483648 is the smallest negative value in 32 bits, which indicates an overflow, thus infinity.

For me infinite aperture doesn't make any sense, it's the depth of field, or hyperfocal. An aperture is measured in f/ and logically the maximum value is f/1 and the smallest I know in any standard camera is f/32, thus 1/32

xperseguers commented 10 months ago

Aperture = size of the opening to the diaphragm:

image

xperseguers commented 10 months ago

=> the aperture for this photo makes no sense, is "wrong" and should be considered "empty".

sypets commented 10 months ago

That makes sense.

xperseguers commented 7 months ago

This should help, please test:

diff --git a/Configuration/Services/ExifTool/default.json b/Configuration/Services/ExifTool/default.json
index 8e6b701..6107d02 100644
--- a/Configuration/Services/ExifTool/default.json
+++ b/Configuration/Services/ExifTool/default.json
@@ -163,7 +163,7 @@
   },
   {
     "FAL": "aperture",
-    "DATA": "Aperture"
+    "DATA": "Aperture->Causal\\Extractor\\Utility\\Number::extractFloat"
   },
   {
    "FAL": "flash",
diff --git a/Configuration/Services/Tika/default.json b/Configuration/Services/Tika/default.json
index 71efccc..095f069 100644
--- a/Configuration/Services/Tika/default.json
+++ b/Configuration/Services/Tika/default.json
@@ -163,7 +163,7 @@
   },
   {
     "FAL": "aperture",
-    "DATA": "exif:FNumber"
+    "DATA": "exif:FNumber->Causal\\Extractor\\Utility\\Number::extractFloat"
   },
   {
     "FAL": "flash",
sypets commented 7 months ago

@xperseguers I tested with branch bugfix/77-infinite-aperture:

composer require causal/extractor:dev-bugfix/77-infinite-aperture

I uploaded a file which caused exception on metadata extraction due to invalid aperture "Inf" in previous version.

This is now ok!