Problems trying to write xmp metadata to image files
Posted: 2014-01-13T08:55:16-07:00
Hi, I'm writing a small tool that gets images from Flickr, retrieves various bit of information about them using the Flickr API (title, tags, owner, copyright info, date taken etc) and then creates local versions of the files with text overlays, and with appropriate metadata embedded, ideally in xmp format. I work with historic images (both my own, and public domain images like Flickr Commons) and one of the key things to set is the DateCreated so that the images can be shown on timelines etc. An important thing to note is that the original files could have existing metadata in all sorts of formats, or indeed none at all. So my plans was to use
where xmp.xml contains an xmp template (see static test version http://www.whatsthatpicture.com/datedpics/xmp.xml , taken from viewtopic.php?f=1&t=11744&view=next)
I'm wondering if I have a simple syntax problem as this doesn't seem to be setting the metadata in a way that it can be recognised.
For debugging I have included
both before and after the metadata is set. For the test image http://www.whatsthatpicture.com/datedpi ... 31c0_o.jpg (from http://www.flickr.com/photos/george_eas ... 420686758/) this gives
which looks to be OK.
If I view the file in Windows Explorer I can see the new date taken (11/07/1980) but when I transfer it to my Android smartphone and view it in the FStop app and sort by date taken (one of the main reasons I want to do this) it just appears as an image created today. When I inspect the saved file (http://www.whatsthatpicture.com/datedpi ... 31c0_o.jpg) in for example Exiv2 it doesn't show any metadata, suggesting to me that there may be a syntax error or some sort of coruption. And if I actually inspect the file in a text editor I can see the full xmp block, but just before that, on the very first line, there's a short string that includes the text 'http://ns.adobe.com/xap/1.0/' duplicating what is in the xmp block below.
Sorry for the long-winded explanation, but is there anything obvious that I'm doing wrong?
Code: Select all
$image->stripImage();
$profile = file_get_contents('xmp.xml');
$image->setImageProfile('xmp',$profile);
I'm wondering if I have a simple syntax problem as this doesn't seem to be setting the metadata in a way that it can be recognised.
For debugging I have included
Code: Select all
$profilesArray = $image->getImageProfiles("*",false);
echo '<br>Profiles:<br>';
print_r($profilesArray);
$exifArray = $image->getImageProperties("*");
echo 'Image properties:<br>';
print_r($exifArray);
Code: Select all
Input
Profiles:
Array
(
[0] => 8bim
[1] => icc
[2] => iptc
[3] => xmp
)
Image properties:
Array
(
[date:create] => 2014-01-13T15:32:06+00:00
[date:modify] => 2014-01-13T15:32:06+00:00
[jpeg:colorspace] => 2
[jpeg:sampling-factor] => 2x2,1x1,1x1
[photoshop:Headline] => Portrait of unidentified woman, ca. 1855
[photoshop:Instructions] => daguerreotype
[rdf:Alt] =>
)
Output
Profiles:
Array
(
[0] => xmp
)
Image properties:
Array
(
[aux:Firmware] => 1.0.3
[aux:FlashCompensation] => 0/1
[aux:ImageNumber] => 0
[aux:Lens] => 18.0-55.0 mm
[aux:LensInfo] => 18/1 55/1 0/0 0/0
[aux:OwnerName] => unknown
[aux:SerialNumber] => 2630711820
[crs:AlreadyApplied] => True
[crs:BlueHue] => 0
[crs:BlueSaturation] => 0
[crs:Brightness] => +35
[crs:CameraProfile] => ACR 3.1
[crs:ChromaticAberrationB] => 0
[crs:ChromaticAberrationR] => 0
[crs:ColorNoiseReduction] => 25
[crs:Contrast] => +29
[crs:ConvertToGrayscale] => False
[crs:Exposure] => +0.95
[crs:FillLight] => 0
[crs:GreenHue] => 0
[crs:GreenSaturation] => 0
[crs:HasCrop] => False
[crs:HasSettings] => True
[crs:HighlightRecovery] => 0
[crs:HueAdjustmentAqua] => 0
[crs:HueAdjustmentBlue] => 0
[crs:HueAdjustmentGreen] => 0
[crs:HueAdjustmentMagenta] => 0
[crs:HueAdjustmentOrange] => 0
[crs:HueAdjustmentPurple] => 0
[crs:HueAdjustmentRed] => 0
[crs:HueAdjustmentYellow] => 0
[crs:LuminanceAdjustmentAqua] => 0
[crs:LuminanceAdjustmentBlue] => 0
[crs:LuminanceAdjustmentGreen] => 0
[crs:LuminanceAdjustmentMagenta] => 0
[crs:LuminanceAdjustmentOrange] => 0
[crs:LuminanceAdjustmentPurple] => 0
[crs:LuminanceAdjustmentRed] => 0
[crs:LuminanceAdjustmentYellow] => 0
[crs:LuminanceSmoothing] => 0
[crs:ParametricDarks] => 0
[crs:ParametricHighlights] => 0
[crs:ParametricHighlightSplit] => 75
[crs:ParametricLights] => 0
[crs:ParametricMidtoneSplit] => 50
[crs:ParametricShadows] => 0
[crs:ParametricShadowSplit] => 25
[crs:RawFileName] => Image_0221.CR2
[crs:RedHue] => 0
[crs:RedSaturation] => 0
[crs:Saturation] => 0
[crs:SaturationAdjustmentAqua] => 0
[crs:SaturationAdjustmentBlue] => 0
[crs:SaturationAdjustmentGreen] => 0
[crs:SaturationAdjustmentMagenta] => 0
[crs:SaturationAdjustmentOrange] => 0
[crs:SaturationAdjustmentPurple] => 0
[crs:SaturationAdjustmentRed] => 0
[crs:SaturationAdjustmentYellow] => 0
[crs:Shadows] => 28
[crs:ShadowTint] => 0
[crs:Sharpness] => 25
[crs:SplitToningBalance] => 0
[crs:SplitToningHighlightHue] => 0
[crs:SplitToningHighlightSaturation] => 0
[crs:SplitToningShadowHue] => 0
[crs:SplitToningShadowSaturation] => 0
[crs:Temperature] => 3900
[crs:Tint] => +9
[crs:ToneCurveName] => Medium Contrast
[crs:Version] => 3.7
[crs:Vibrance] => 0
[crs:VignetteAmount] => 0
[crs:WhiteBalance] => Auto
[dc:format] => image/jpeg
[exif:ApertureValue] => 8918863/1000000
[exif:ColorSpace] => -1
[exif:CustomRendered] => 0
[exif:DateTimeDigitized] => 2007-06-30T19:02:24+01:00
[exif:DateTimeOriginal] => 1980-06-30T19:02:24+01:00
[exif:ExifVersion] => 0221
[exif:ExposureBiasValue] => 2/2
[exif:ExposureMode] => 0
[exif:ExposureProgram] => 3
[exif:ExposureTime] => 1/1
[exif:Fired] => False
[exif:FNumber] => 22/1
[exif:FocalLength] => 25/1
[exif:FocalPlaneResolutionUnit] => 2
[exif:FocalPlaneXResolution] => 3456000/874
[exif:FocalPlaneYResolution] => 2304000/582
[exif:Function] => False
[exif:MeteringMode] => 5
[exif:Mode] => 2
[exif:NativeDigest] => 36864,40960,40961,37121,37122,40962,40963,37510,40964,36867,36868,33434,33437,34850,34852,34855,34856,37377,37378,37379,37380,37381,37382,37383,37384,37385,37386,37396,41483,41484,41486,41487,41488,41492,41493,41495,41728,41729,41730,41985,41986,41987,41988,41989,41990,41991,41992,41993,41994,41995,41996,42016,0,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,22,23,24,25,26,27,28,30;F4B91C814662CABD5B25B5A82B132B5C
[exif:PixelXDimension] => 663
[exif:PixelYDimension] => 2083
[exif:RedEyeMode] => False
[exif:Return] => 0
[exif:SceneCaptureType] => 0
[exif:ShutterSpeedValue] => 0/1
[exif:WhiteBalance] => 0
[jpeg:colorspace] => 2
[jpeg:sampling-factor] => 2x2,1x1,1x1
[photoshop:ColorMode] => 3
[photoshop:Headline] => Portrait of unidentified woman, ca. 1855
[photoshop:History] =>
[photoshop:ICCProfile] => Adobe RGB (1998)
[photoshop:Instructions] => daguerreotype
[photoshop:SidecarForExtension] => CR2
[rdf:Alt] =>
[stRef:documentID] => uuid:2F3B63899D2FDC118774F57B17068D27
[stRef:instanceID] => uuid:2F3B63899D2FDC118774F57B17068D27
[tiff:Make] => Canon
[tiff:Model] => Canon EOS 350D DIGITAL
[tiff:NativeDigest] => 256,257,258,259,262,274,277,284,530,531,282,283,296,301,318,319,529,532,306,270,271,272,305,315,33432;83EF8D05AF241CA9C81D662E490CCF1C
[tiff:Orientation] => 1
[tiff:ResolutionUnit] => 2
[tiff:XResolution] => 2400000/10000
[tiff:YResolution] => 2400000/10000
[xap:CreateDate] => 1980-07-11T12:01:12+01:00
[xap:CreatorTool] => Adobe Photoshop CS2 Windows
[xap:MetadataDate] => 2007-07-11T12:01:12+01:00
[xap:ModifyDate] => 2007-07-11T12:01:12+01:00
[xap:Rating] => 0
[xapMM:DocumentID] => uuid:303B63899D2FDC118774F57B17068D27
[xapMM:InstanceID] => uuid:313B63899D2FDC118774F57B17068D27
)
If I view the file in Windows Explorer I can see the new date taken (11/07/1980) but when I transfer it to my Android smartphone and view it in the FStop app and sort by date taken (one of the main reasons I want to do this) it just appears as an image created today. When I inspect the saved file (http://www.whatsthatpicture.com/datedpi ... 31c0_o.jpg) in for example Exiv2 it doesn't show any metadata, suggesting to me that there may be a syntax error or some sort of coruption. And if I actually inspect the file in a text editor I can see the full xmp block, but just before that, on the very first line, there's a short string that includes the text 'http://ns.adobe.com/xap/1.0/' duplicating what is in the xmp block below.
Sorry for the long-winded explanation, but is there anything obvious that I'm doing wrong?