Metadata: Add keywords tests #1153

This commit is contained in:
Michael Mayer 2021-05-01 10:52:28 +02:00
parent f0b627b8f6
commit 2d7becdbbc
4 changed files with 311 additions and 0 deletions

View File

@ -460,4 +460,24 @@ func TestExif(t *testing.T) {
assert.Equal(t, 28, data.FocalLength)
assert.Equal(t, 1, int(data.Orientation))
})
t.Run("keywords.jpg", func(t *testing.T) {
data, err := Exif("testdata/keywords.jpg", fs.FormatJpeg)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, CodecUnknown, data.Codec)
assert.Equal(t, "", data.Title)
assert.Equal(t, "", data.Artist)
assert.Equal(t, Keywords{"flash"}, data.Keywords)
assert.Equal(t, "", data.Description)
assert.Equal(t, "", data.Copyright)
assert.Equal(t, "Canon", data.CameraMake)
assert.Equal(t, "Canon EOS 7D", data.CameraModel)
assert.Equal(t, "", data.LensMake)
assert.Equal(t, "EF70-200mm f/4L IS USM", data.LensModel)
assert.Equal(t, 1, data.Orientation)
})
}

View File

@ -753,4 +753,24 @@ func TestJSON(t *testing.T) {
assert.Equal(t, 1, data.Orientation)
assert.Equal(t, "", data.Projection)
})
t.Run("keywords.json", func(t *testing.T) {
data, err := JSON("testdata/keywords.json", "")
if err != nil {
t.Fatal(err)
}
assert.Equal(t, CodecJpeg, data.Codec)
assert.Equal(t, "", data.Title)
assert.Equal(t, "", data.Artist)
assert.Equal(t, Keywords{"alo", "cactus", "ever", "lang", "sonne"}, data.Keywords)
assert.Equal(t, "", data.Description)
assert.Equal(t, "", data.Copyright)
assert.Equal(t, "Canon", data.CameraMake)
assert.Equal(t, "Canon EOS 7D", data.CameraModel)
assert.Equal(t, "", data.LensMake)
assert.Equal(t, "EF70-200mm f/4L IS USM", data.LensModel)
assert.Equal(t, 1, data.Orientation)
})
}

BIN
internal/meta/testdata/keywords.jpg vendored Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

271
internal/meta/testdata/keywords.json vendored Normal file
View File

@ -0,0 +1,271 @@
[{
"SourceFile": "keywords.jpg",
"ExifToolVersion": 12.05,
"FileName": "keywords.jpg",
"Directory": ".",
"FileSize": "3.2 MB",
"FileModifyDate": "2021:05:01 08:13:39+00:00",
"FileAccessDate": "2021:05:01 08:45:05+00:00",
"FileInodeChangeDate": "2021:05:01 08:45:02+00:00",
"FilePermissions": "rwxrwxr-x",
"FileType": "JPEG",
"FileTypeExtension": "jpg",
"MIMEType": "image/jpeg",
"ExifByteOrder": "Little-endian (Intel, II)",
"Make": "Canon",
"Model": "Canon EOS 7D",
"Orientation": "Horizontal (normal)",
"XResolution": 240,
"YResolution": 240,
"ResolutionUnit": "inches",
"Software": "Adobe Photoshop CS5 Macintosh",
"ModifyDate": "2012:04:16 14:19:30",
"ExposureTime": "1/320",
"FNumber": 4.0,
"ExposureProgram": "Aperture-priority AE",
"ISO": 100,
"ExifVersion": "0221",
"DateTimeOriginal": "2012:04:16 13:02:13",
"CreateDate": "2012:04:16 13:02:13",
"ShutterSpeedValue": "1/320",
"ApertureValue": 4.0,
"ExposureCompensation": "+1",
"MaxApertureValue": 4.0,
"SubjectDistance": "1.18 m",
"MeteringMode": "Multi-segment",
"FocalLength": "183.0 mm",
"SubSecTime": "00",
"SubSecTimeOriginal": "00",
"SubSecTimeDigitized": "00",
"ColorSpace": "sRGB",
"ExifImageWidth": 3289,
"ExifImageHeight": 3289,
"FocalPlaneXResolution": 5715.545755,
"FocalPlaneYResolution": 5808.403361,
"FocalPlaneResolutionUnit": "inches",
"CustomRendered": "Normal",
"ExposureMode": "Auto",
"WhiteBalance": "Auto",
"SceneCaptureType": "Standard",
"SerialNumber": 2581203848,
"LensInfo": "70-200mm f/?",
"LensModel": "EF70-200mm f/4L IS USM",
"Compression": "JPEG (old-style)",
"ThumbnailOffset": 880,
"ThumbnailLength": 11164,
"CurrentIPTCDigest": "0b1672ef75f2a34c8d59191b73ae0610",
"CodedCharacterSet": "UTF8",
"EnvelopeRecordVersion": 4,
"ApplicationRecordVersion": 0,
"TimeCreated": "13:02:13+00:00",
"Keywords": ["cactus","ever","lang","alo","sonne"],
"IPTCDigest": "88821b58d379d38c349207623eaaee66",
"DisplayedUnitsX": "inches",
"DisplayedUnitsY": "inches",
"PrintStyle": "Centered",
"PrintPosition": "0 0",
"PrintScale": 1,
"GlobalAngle": 30,
"GlobalAltitude": 30,
"URL_List": [],
"SlicesGroupName": "IMG_2393",
"NumSlices": 1,
"PixelAspectRatio": 1,
"PhotoshopThumbnail": "(Binary data 11164 bytes, use -b option to extract)",
"HasRealMergedData": "Yes",
"WriterName": "Adobe Photoshop",
"ReaderName": "Adobe Photoshop CS5",
"PhotoshopQuality": 11,
"PhotoshopFormat": "Optimized",
"ProgressiveScans": "3 Scans",
"XMPToolkit": "Image::ExifTool 11.88",
"ApproximateFocusDistance": 1.18,
"Firmware": "1.2.5",
"FlashCompensation": 0,
"ImageNumber": 0,
"Lens": "EF70-200mm f/4L IS USM",
"Format": "image/jpeg",
"FlashFired": true,
"FlashFunction": false,
"FlashMode": "On",
"FlashRedEyeMode": false,
"FlashReturn": "No return detection",
"ColorMode": "RGB",
"DateCreated": "2012:04:16 13:02:13",
"ICCProfileName": "sRGB IEC61966-2.1",
"MetadataDate": "2012:04:16 14:19:30+02:00",
"Rating": 0,
"DerivedFromDocumentID": "xmp.did:D7525213E0226811822ADAA4A44A712D",
"DerivedFromInstanceID": "xmp.iid:1C383279DF226811871FEE482A685D21",
"DerivedFromOriginalDocumentID": "184118427A12BEED87E79B1F2585545C",
"DocumentID": "xmp.did:D7525213E0226811822ADAA4A44A712D",
"HistoryAction": ["derived","saved","saved","converted","derived","saved"],
"HistoryParameters": ["converted from image/x-canon-cr2 to image/tiff","from image/tiff to image/jpeg","converted from image/tiff to image/jpeg"],
"HistoryChanged": ["/","/","/"],
"HistoryInstanceID": ["xmp.iid:D7525213E0226811822ADAA4A44A712D","xmp.iid:1C383279DF226811871FEE482A685D21","xmp.iid:1D383279DF226811871FEE482A685D21"],
"HistorySoftwareAgent": ["Adobe Photoshop Camera Raw 6.6 (Macintosh)","Adobe Photoshop CS5 Macintosh","Adobe Photoshop CS5 Macintosh"],
"HistoryWhen": ["2012:04:16 14:10:26+02:00","2012:04:16 14:19:30+02:00","2012:04:16 14:19:30+02:00"],
"InstanceID": "xmp.iid:1D383279DF226811871FEE482A685D21",
"OriginalDocumentID": "184118427A12BEED87E79B1F2585545C",
"AlreadyApplied": true,
"BlueHue": 0,
"BlueSaturation": 0,
"Brightness": "+50",
"CameraProfile": "Adobe Standard",
"CameraProfileDigest": "41F68367DA3B31B07AB631D81D0E942D",
"ChromaticAberrationB": 0,
"ChromaticAberrationR": 0,
"Clarity": "+21",
"ColorNoiseReduction": 25,
"ColorNoiseReductionDetail": 50,
"Contrast": "+25",
"ConvertToGrayscale": false,
"CropAngle": 0,
"CropBottom": 0.951777,
"CropConstrainToWarp": 1,
"CropHeight": 1,
"CropLeft": 0.241963,
"CropRight": 0.876481,
"CropTop": 0,
"CropUnit": "Unknown (3)",
"CropWidth": 1,
"Defringe": 0,
"Exposure": 0.00,
"FillLight": 0,
"GrainAmount": 0,
"GreenHue": 0,
"GreenSaturation": 0,
"HasCrop": true,
"HasSettings": true,
"HighlightRecovery": 0,
"HueAdjustmentAqua": 0,
"HueAdjustmentBlue": 0,
"HueAdjustmentGreen": 0,
"HueAdjustmentMagenta": 0,
"HueAdjustmentOrange": 0,
"HueAdjustmentPurple": 0,
"HueAdjustmentRed": 0,
"HueAdjustmentYellow": 0,
"LensManualDistortionAmount": 0,
"LensProfileEnable": 0,
"LensProfileSetup": "LensDefaults",
"LuminanceAdjustmentAqua": 0,
"LuminanceAdjustmentBlue": 0,
"LuminanceAdjustmentGreen": 0,
"LuminanceAdjustmentMagenta": 0,
"LuminanceAdjustmentOrange": 0,
"LuminanceAdjustmentPurple": 0,
"LuminanceAdjustmentRed": 0,
"LuminanceAdjustmentYellow": 0,
"LuminanceSmoothing": 0,
"ParametricDarks": 0,
"ParametricHighlightSplit": 75,
"ParametricHighlights": "+1",
"ParametricLights": 0,
"ParametricMidtoneSplit": 50,
"ParametricShadowSplit": 25,
"ParametricShadows": -58,
"PerspectiveHorizontal": 0,
"PerspectiveRotate": 0.0,
"PerspectiveScale": 100,
"PerspectiveVertical": 0,
"PostCropVignetteAmount": 0,
"ProcessVersion": 5.7,
"RawFileName": "IMG_2393.CR2",
"RedHue": 0,
"RedSaturation": 0,
"Saturation": 0,
"SaturationAdjustmentAqua": 0,
"SaturationAdjustmentBlue": 0,
"SaturationAdjustmentGreen": 0,
"SaturationAdjustmentMagenta": 0,
"SaturationAdjustmentOrange": 0,
"SaturationAdjustmentPurple": 0,
"SaturationAdjustmentRed": 0,
"SaturationAdjustmentYellow": 0,
"ShadowTint": 0,
"Shadows": 5,
"SharpenDetail": 25,
"SharpenEdgeMasking": 0,
"SharpenRadius": "+1.0",
"Sharpness": 25,
"SplitToningBalance": 0,
"SplitToningHighlightHue": 0,
"SplitToningHighlightSaturation": 0,
"SplitToningShadowHue": 0,
"SplitToningShadowSaturation": 0,
"ColorTemperature": 4900,
"Tint": "+15",
"ToneCurve": ["0, 0","32, 22","64, 56","128, 128","192, 196","255, 255"],
"ToneCurveName": "Medium Contrast",
"Version": 6.6,
"Vibrance": "+32",
"VignetteAmount": 0,
"ProfileCMMType": "Linotronic",
"ProfileVersion": "2.1.0",
"ProfileClass": "Display Device Profile",
"ColorSpaceData": "RGB ",
"ProfileConnectionSpace": "XYZ ",
"ProfileDateTime": "1998:02:09 06:49:00",
"ProfileFileSignature": "acsp",
"PrimaryPlatform": "Microsoft Corporation",
"CMMFlags": "Not Embedded, Independent",
"DeviceManufacturer": "Hewlett-Packard",
"DeviceModel": "sRGB",
"DeviceAttributes": "Reflective, Glossy, Positive, Color",
"RenderingIntent": "Perceptual",
"ConnectionSpaceIlluminant": "0.9642 1 0.82491",
"ProfileCreator": "Hewlett-Packard",
"ProfileID": 0,
"ProfileCopyright": "Copyright (c) 1998 Hewlett-Packard Company",
"ProfileDescription": "sRGB IEC61966-2.1",
"MediaWhitePoint": "0.95045 1 1.08905",
"MediaBlackPoint": "0 0 0",
"RedMatrixColumn": "0.43607 0.22249 0.01392",
"GreenMatrixColumn": "0.38515 0.71687 0.09708",
"BlueMatrixColumn": "0.14307 0.06061 0.7141",
"DeviceMfgDesc": "IEC http://www.iec.ch",
"DeviceModelDesc": "IEC 61966-2.1 Default RGB colour space - sRGB",
"ViewingCondDesc": "Reference Viewing Condition in IEC61966-2.1",
"ViewingCondIlluminant": "19.6445 20.3718 16.8089",
"ViewingCondSurround": "3.92889 4.07439 3.36179",
"ViewingCondIlluminantType": "D50",
"Luminance": "76.03647 80 87.12462",
"MeasurementObserver": "CIE 1931",
"MeasurementBacking": "0 0 0",
"MeasurementGeometry": "Unknown",
"MeasurementFlare": "0.999%",
"MeasurementIlluminant": "D65",
"Technology": "Cathode Ray Tube Display",
"RedTRC": "(Binary data 2060 bytes, use -b option to extract)",
"GreenTRC": "(Binary data 2060 bytes, use -b option to extract)",
"BlueTRC": "(Binary data 2060 bytes, use -b option to extract)",
"DCTEncodeVersion": 100,
"APP14Flags0": "[14]",
"APP14Flags1": "(none)",
"ColorTransform": "YCbCr",
"ImageWidth": 3289,
"ImageHeight": 3289,
"EncodingProcess": "Baseline DCT, Huffman coding",
"BitsPerSample": 8,
"ColorComponents": 3,
"YCbCrSubSampling": "YCbCr4:4:4 (1 1)",
"Aperture": 4.0,
"ImageSize": "3289x3289",
"LensID": "EF70-200mm f/4L IS USM",
"Megapixels": 10.8,
"ScaleFactor35efl": 1.6,
"ShutterSpeed": "1/320",
"SubSecCreateDate": "2012:04:16 13:02:13.00",
"SubSecDateTimeOriginal": "2012:04:16 13:02:13.00",
"SubSecModifyDate": "2012:04:16 14:19:30.00",
"ThumbnailImage": "(Binary data 11164 bytes, use -b option to extract)",
"DateTimeCreated": "2012:04:16 13:02:13+00:00",
"Flash": "On, Fired",
"CircleOfConfusion": "0.019 mm",
"DOF": "0.005 m (1.177 - 1.183 m)",
"FOV": "7.2 deg",
"FocalLength35efl": "183.0 mm (35 mm equivalent: 287.4 mm)",
"HyperfocalDistance": "437.57 m",
"LightValue": 12.3
}]