drewnoakes / metadata-extractor-dotnet

Extracts Exif, IPTC, XMP, ICC and other metadata from image, video and audio files
Other
932 stars 165 forks source link

Support for photoshop tags #87

Open PpChailley opened 7 years ago

PpChailley commented 7 years ago

Support for the following namespace could be very useful: http://ns.adobe.com/photoshop/1.0/

In particular it contains a photoshop:DateCreated tag that includes milliseconds. It's the only effective way I know to differentiate and sort images shot in a burst

Data example as reported by photoshop CS6 on a Canon CR2 (raw) image (access through File> Info > Raw data or Ctrl-Alt-Shift-I):

   <rdf:Description rdf:about=""
        xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
         <photoshop:DateCreated>2016-08-01T06:50:09.095</photoshop:DateCreated>
         <photoshop:EmbeddedXMPDigest>00000000000000000000000000000000</photoshop:EmbeddedXMPDigest>
         <photoshop:ColorMode>3</photoshop:ColorMode>
  </rdf:Description>
drewnoakes commented 7 years ago

Use the XmpMeta object returned from the XmpDirectory.XmpMeta property. That gives you full access to all XMP properties.

PpChailley commented 7 years ago

(I'm not sure it's still a feature request, it sounds more like a support question. Sorry if out of place)

For some reason, I can't find any XmpMeta on the results. I tried

         var dirs = ImageMetadataReader.ReadMetadata(file.FullName);
         var xmp = dirs.OfType<XmpDirectory>().SingleOrDefault();    // returns null

Also tried to call the TIFF reader directly, I get (unsurprisingly) the same results except for the FileDIrectory :

        using (var stream = new System.IO.FileStream(file.FullName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read))
        {
            var directories = new List<MetadataExtractor.Directory>();
            var handler = new ExifTiffHandler(directories);
            TiffReader.ProcessTiff(new IndexedCapturingReader(stream), handler);
            var found = directories.OfType<XmpDirectory>().SingleOrDefault();  // also null
        }

Still the XML in the original post comes from the same file (triple checked)

CR2 file : https://www.dropbox.com/s/7wl9syuqeqqlt04/_MG_3179.CR2?dl=0 XMP "sidecar" file (created by Lightroom and edited by Photoshop) : https://www.dropbox.com/s/4ordd41lq37m1u5/_MG_3179.xmp?dl=0 (note the exif:DateTimeOriginal tag in that file that has milliseconds. I suppose Lightroom kind of "mixed up" different tags)

drewnoakes commented 7 years ago

Ok I see what you mean. Thanks for the sample images.

Seems there's no XMP in that CR2 file (at least not in plain text). You could process the sidecar file directly using xmp-core-dotnet to access an XmpMeta object, but I'm assuming the CR2 is the original source for data in the sidecar, so the data must be in there.

The library outputs for your CR2 file:

[Exif IFD0] Image Width = 4752 pixels
[Exif IFD0] Image Height = 3168 pixels
[Exif IFD0] Bits Per Sample = 8 8 8 bits/component/pixel
[Exif IFD0] Compression = JPEG (old-style)
[Exif IFD0] Make = Canon
[Exif IFD0] Model = Canon EOS 50D
[Exif IFD0] Strip Offsets = 57276
[Exif IFD0] Orientation = Top, left side (Horizontal / normal)
[Exif IFD0] Strip Byte Counts = 1394086 bytes
[Exif IFD0] X Resolution = 72 dots per inch
[Exif IFD0] Y Resolution = 72 dots per inch
[Exif IFD0] Resolution Unit = Inch
[Exif IFD0] Date/Time = 2016:08:01 06:50:09
[Exif IFD0] Artist = 
[Exif IFD0] Copyright = 
[Exif SubIFD] Exposure Time = 1/750 sec
[Exif SubIFD] F-Number = f/8.0
[Exif SubIFD] Exposure Program = Manual control
[Exif SubIFD] ISO Speed Ratings = 200
[Exif SubIFD] Exif Version = 2.21
[Exif SubIFD] Date/Time Original = 2016:08:01 06:50:09
[Exif SubIFD] Date/Time Digitized = 2016:08:01 06:50:09
[Exif SubIFD] Components Configuration = YCbCr
[Exif SubIFD] Shutter Speed Value = 1/724 sec
[Exif SubIFD] Aperture Value = f/8.0
[Exif SubIFD] Exposure Bias Value = 0 EV
[Exif SubIFD] Metering Mode = Multi-segment
[Exif SubIFD] Flash = Flash did not fire, auto
[Exif SubIFD] Focal Length = 105 mm
[Exif SubIFD] User Comment = 
[Exif SubIFD] Sub-Sec Time = 15
[Exif SubIFD] Sub-Sec Time Original = 15
[Exif SubIFD] Sub-Sec Time Digitized = 15
[Exif SubIFD] FlashPix Version = 1.00
[Exif SubIFD] Color Space = Undefined
[Exif SubIFD] Exif Image Width = 4752 pixels
[Exif SubIFD] Exif Image Height = 3168 pixels
[Exif SubIFD] Focal Plane X Resolution = 149/792000 inches
[Exif SubIFD] Focal Plane Y Resolution = 199/1056000 inches
[Exif SubIFD] Focal Plane Resolution Unit = Inches
[Exif SubIFD] Custom Rendered = Normal process
[Exif SubIFD] Exposure Mode = Manual exposure
[Exif SubIFD] White Balance Mode = Auto white balance
[Exif SubIFD] Scene Capture Type = Standard
[Canon Makernote] Unknown tag (0xc100) = 98
[Canon Makernote] Macro Mode = Normal
[Canon Makernote] Self Timer Delay = Self timer not used
[Canon Makernote] Quality = Unknown (4)
[Canon Makernote] Flash Mode = No flash fired
[Canon Makernote] Continuous Drive Mode = Unknown (5)
[Canon Makernote] Unknown Camera Setting 2 = 0
[Canon Makernote] Focus Mode = AI Focus
[Canon Makernote] Unknown Camera Setting 3 = 0
[Canon Makernote] Record Mode = CR2
[Canon Makernote] Image Size = Unknown (65535)
[Canon Makernote] Easy Shooting Mode = Manual
[Canon Makernote] Digital Zoom = No digital zoom
[Canon Makernote] Contrast = Normal
[Canon Makernote] Saturation = Normal
[Canon Makernote] Sharpness = Unknown (32767)
[Canon Makernote] Iso = 16383
[Canon Makernote] Metering Mode = Evaluative
[Canon Makernote] Focus Type = Unknown (2)
[Canon Makernote] AF Point Selected = Unknown (0)
[Canon Makernote] Exposure Mode = Manual
[Canon Makernote] Unknown Camera Setting 7 = 65535
[Canon Makernote] Lens Type = Canon EF 24-105mm f/4L IS
[Canon Makernote] Long Focal Length = 105 1
[Canon Makernote] Short Focal Length = 24 1
[Canon Makernote] Focal Units per mm = 1
[Canon Makernote] Max Aperture = f/4.0
[Canon Makernote] Min Aperture = f/22.6
[Canon Makernote] Flash Activity = Flash did not fire
[Canon Makernote] Flash Details = Unknown (0)
[Canon Makernote] Focus Continuous = Single
[Canon Makernote] AE Setting = Normal AE
[Canon Makernote] Focus Mode = Unknown (65535)
[Canon Makernote] Display Aperture = 65535
[Canon Makernote] Zoom Source Width = 65535
[Canon Makernote] Zoom Target Width = 0
[Canon Makernote] Unknown tag (0xc124) = 0
[Canon Makernote] Spot Metering Mode = Center
[Canon Makernote] Photo Effect = Off
[Canon Makernote] Manual Flash Output = Unknown (65535)
[Canon Makernote] Unknown tag (0xc128) = 65535
[Canon Makernote] Color Tone = 0
[Canon Makernote] Unknown tag (0xc12a) = 0
[Canon Makernote] Unknown tag (0xc12b) = 32767
[Canon Makernote] Unknown tag (0xc12c) = 65535
[Canon Makernote] SRAW Quality = Unknown (65535)
[Canon Makernote] Unknown tag (0xc12e) = 0
[Canon Makernote] Unknown tag (0xc12f) = 0
[Canon Makernote] Unknown tag (0xc130) = 65535
[Canon Makernote] Unknown tag (0xc200) = 0
[Canon Makernote] Unknown tag (0xc201) = 105
[Canon Makernote] Unknown tag (0xc202) = 63601
[Canon Makernote] Unknown tag (0xc203) = 21818
[Canon Makernote] Unknown tag (0x0003) = 0 0 0 0
[Canon Makernote] Unknown tag (0xc400) = 68
[Canon Makernote] Auto ISO = 0
[Canon Makernote] Base ISO = 192
[Canon Makernote] Measured EV = 312
[Canon Makernote] Target Aperture = 192
[Canon Makernote] Target Exposure Time = 304
[Canon Makernote] Exposure Compensation = 0
[Canon Makernote] White Balance = 0
[Canon Makernote] Slow Shutter = 3
[Canon Makernote] Sequence Number = 0
[Canon Makernote] Optical Zoom Code = 8
[Canon Makernote] Unknown tag (0xc40b) = 8
[Canon Makernote] Camera Temperature = 163
[Canon Makernote] Flash Guide Number = 0
[Canon Makernote] AF Points in Focus = 0
[Canon Makernote] Flash Exposure Compensation = 0
[Canon Makernote] Auto Exposure Bracketing = 0
[Canon Makernote] AEB Bracket Value = 0
[Canon Makernote] Control Mode = 1
[Canon Makernote] Focus Distance Upper = 0
[Canon Makernote] Focus Distance Lower = 0
[Canon Makernote] F Number = 192
[Canon Makernote] Exposure Time = 304
[Canon Makernote] Measured EV 2 = 169
[Canon Makernote] Bulb Duration = 0
[Canon Makernote] Unknown tag (0xc419) = 0
[Canon Makernote] Camera Type = 248
[Canon Makernote] Auto Rotate = 65535
[Canon Makernote] ND Filter = 65535
[Canon Makernote] Self Timer 2 = 65535
[Canon Makernote] Unknown tag (0xc41e) = 65535
[Canon Makernote] Unknown tag (0xc41f) = 0
[Canon Makernote] Unknown tag (0xc420) = 0
[Canon Makernote] Flash Output = 0
[Canon Makernote] Image Type = Canon EOS 50D
[Canon Makernote] Firmware Version = Firmware Version 1.0.9
[Canon Makernote] Owner Name = 
[Canon Makernote] Camera Serial Number = 00D700252
[Canon Makernote] Camera Info Array = [1536 values]
[Canon Makernote] Canon Model ID = 2147484257
[Canon Makernote] Thumbnail Image Valid Area = 0 159 7 112
[Canon Makernote] Serial Number Format = 2684354560
[Canon Makernote] Unknown tag (0x0019) = 1
[Canon Makernote] AF Info Array 2 = [48 values]
[Canon Makernote] Original Decision Data Offset = 3284
[Canon Makernote] File Info Array = [26 values]
[Canon Makernote] Lens Model = EF24-105mm f/4L IS USM
[Canon Makernote] Serial Info Array = P0721287
[Canon Makernote] Dust Removal Data = [1024 values]
[Canon Makernote] Crop Info = 0 0 0 0
[Canon Makernote] Custom Functions Array 2 = [93 values]
[Canon Makernote] Aspect Information Array = 0 4752 3168 0 0
[Canon Makernote] Processing Information Array = 28 0 0 0 0 0 0 0 65535 5200 132 0 0 0
[Canon Makernote] Measured Color Array = 12 507 1024 1024 735 0
[Canon Makernote] Color Space = 2
[Canon Makernote] VRD Offset = 0
[Canon Makernote] Sensor Information Array = [17 values]
[Canon Makernote] Color Data Array 1 = [1250 values]
[Canon Makernote] CRW Parameters = [8520 values]
[Canon Makernote] Unknown tag (0x4005) = [16448 values]
[Canon Makernote] Black Level = 129 129 129
[Canon Makernote] Unknown tag (0x4009) = 0 0 0
[Canon Makernote] Custom Picture Style File Name = 
[Canon Makernote] Unknown tag (0x4011) = [252 values]
[Canon Makernote] Unknown tag (0x4012) = 
[Canon Makernote] Color Info Array = 20 0 0 10 0
[Canon Makernote] Vignetting Correction Array 1 = [116 values]
[Canon Makernote] Vignetting Correction Array 2 = 24 0 1 0 0 0
[Canon Makernote] Unknown tag (0x4017) = 197637 1358954528
[Interoperability] Interoperability Index = Recommended Exif Interoperability Rules (ExifR98)
[Interoperability] Interoperability Version = 1.00
[GPS] GPS Version ID = 2.200
[Exif Thumbnail] Thumbnail Offset = 44436 bytes
[Exif Thumbnail] Thumbnail Length = 12839 bytes
[Exif Thumbnail] Image Width = 604 pixels
[Exif Thumbnail] Image Height = 396 pixels
[Exif Thumbnail] Bits Per Sample = 16 16 16 bits/component/pixel
[Exif Thumbnail] Compression = JPEG (old-style)
[Exif Thumbnail] Photometric Interpretation = RGB
[Exif Thumbnail] Strip Offsets = 2893156
[Exif Thumbnail] Samples Per Pixel = 3 samples/pixel
[Exif Thumbnail] Rows Per Strip = 396 rows/strip
[Exif Thumbnail] Strip Byte Counts = 17702342 bytes
[Exif Thumbnail] Planar Configuration = Chunky (contiguous for each subsampling pixel)
[Exif Thumbnail] Unknown tag (0xc5d9) = 2
[Exif Thumbnail] Unknown tag (0xc6c5) = 1
[Exif Thumbnail] Unknown tag (0xc6dc) = 594 396 9 0
[Exif Thumbnail] Unknown tag (0xc5d8) = 1
[Exif Thumbnail] Unknown tag (0xc5e0) = 3
[Exif Thumbnail] Unknown tag (0xc640) = 2 1616 1600
[File] File Name = _MG_3179.CR2
[File] File Size = 20595498 bytes
[File] File Modified Date = Tue Jan 24 21:18:57 +00:00 2017

I think you can achieve what you need by combining tags. Specifically these:

[Exif SubIFD] Date/Time Original = 2016:08:01 06:50:09
[Exif SubIFD] Date/Time Digitized = 2016:08:01 06:50:09
[Exif SubIFD] Sub-Sec Time = 15
[Exif SubIFD] Sub-Sec Time Original = 15
[Exif SubIFD] Sub-Sec Time Digitized = 15

The XMP sidecar of that CR2 file shows:

photoshop:DateCreated="2016-08-01T06:50:09.15"
photoshop:EmbeddedXMPDigest="00000000000000000000000000000000"
photoshop:SidecarForExtension="CR2"

So it looks like the milliseconds component came from the sub-sec tags.

Those values suggest the number is in tens-of-milliseconds. However it might be a bug (i.e. should be ...09.015). Perhaps test with a few images and let us know. It'd be good to capture this information on the wiki.

I can't see any evidence that the other photoshop: tags actually came from the CR2. Perhaps they were added by Lightroom, derived from other metadata.

PpChailley commented 7 years ago

Those values suggest the number is in tens-of-milliseconds. However it might be a bug (i.e. should be ...09.015)

It's not a bug, though counterintuitive and harder to parse. I checked on several images: 09.15 means 09.150