Windows >
Software Development for Windows Client Forums
>
Windows Imaging Component (WIC)
>
Anybody successfully able to use WIC on Vista SP1or SP2 to read XMP CreatorContactInfo from the Adobe XMP Toolkit version 4+?
Anybody successfully able to use WIC on Vista SP1or SP2 to read XMP CreatorContactInfo from the Adobe XMP Toolkit version 4+?
- I am trying to read embedded metadata from jpeg and tiff images with C# and add them to a database for other uses.
I can successfully read almost everything I need, including my own Photoshop custom XMP template derived metadata, but not any of the Iptc4xmp CreatorContactInfo xmp metadata which I really, REALLY need for my purposes.
If I am reading a blog post by Bob Wlodarczyk (at http://blogs.msdn.com/rwlodarc/archive/2006/03/30/565138.aspx) correctly, the metadata Query strings for jpeg image embedded CreatorContactInfo address metadata:
/xmp/CreatorContactInfo/CiAdrExtadr
and
/xmp/http\:\/\/iptc.org\/std\/Iptc4xmpCore\/1.0\/xmlns\/:CreatorContactInfo/http\:\/\/iptc.org\/std\/Iptc4xmpCore\/1.0\/xmlns\/:CiAdrExtadr
should work successfully in Vista, but my test images (that show the metadata in Photoshop CS2, written by either Photoshop CS2, CS3, or CS4) do not seem to be able to successfully retrieve any CreatorContactInfo metadata items, eg:
BitmapMetadata theBitmapMetadata = ...;
string m_CreatorCiAdrExtadr = theBitmapMetadata.GetQuery( "/xmp/CreatorContactInfo/CiAdrExtadr" ) as string;
in a commandline STAThread marked application (VS2008, Vista Sp1, PresentationCore.dll version 3.0.0.0 runtime version v2.0.50727) ALWAYS seems to throw an Exception "Unexpected type of metadata" and ContainsQuery( "/xmp/CreatorContactInfo/CiAdrExtadr" ) always returns false.
Also, the WICExplorer tool (from the download http://www.microsoft.com/downloads/details.aspx?FamilyID=a6d6ec6a-e4f2-405e-842d-7c3bcb5b1390&displaylang=en) fails to show the CreatorContactInfo in the images, which when extracted reads (for one particular instance):
<Iptc4xmpCore:CreatorContactInfo Iptc4xmpCore:CiAdrExtadr="625 East 14th St 4d" Iptc4xmpCore:CiAdrCity="New York" Iptc4xmpCore:CiAdrRegion="NY" Iptc4xmpCore:CiAdrPcode="10009" Iptc4xmpCore:CiAdrCtry="USA" Iptc4xmpCore:CiTelWork="917.555.1212" Iptc4xmpCore:CiEmailWork="nobody@nowhere.com" Iptc4xmpCore:CiUrlWork="www.nowhere.com"/>
and was generated in this instance by "Adobe XMP Core 4.1-c036 46.276720, Mon Feb 19 2007 22:13:43 " from Photoshop CS3.
Has anyone successfully read this CreatorContactInfo metadata under Vista/XP/Server 2008 using WIC????
If there is an issue under Vista/XP/Server 2008 with the current WIC, will it be possible to successfully read this under Windows 7 WIC RTM (and hopefully in an updated component in these "older" OS's)??
Looking for whatever help I can find without having to use the Adobe SDK and wrapping it in C#, TIA.
- Edited byMichael Beasley Sunday, October 25, 2009 7:35 PM
- Edited byMichael Beasley Sunday, October 25, 2009 7:43 PM
- Edited byMichael Beasley Sunday, October 25, 2009 7:33 PM
Answers
- The release version of the "Platform Update for Windows Vista" shipped via Windows Update yesterday (28 October 2009.
Using the previously compiled application and code referenced immediately above after installing the Platform Update and restarting resulted in getting "Unexpected type of metadata" thrown exceptions for all three test images.
In VS2008 after the update installation and restart, removing the reference to to PresentationCore, re-adding it, then recompiling (and may have only required recompiling - I did not try that first), results in all three test images having their metadata (and specifically the XMP CreatorContactInfo "flattened attribute style" metadata written by the Adobe XMP toolkit version 4) being read correctly for all three images.
Cordially,
Michael Beasley- Marked As Answer byMichael Beasley Thursday, October 29, 2009 7:29 PM
All Replies
- Correcting my own post regarding the PresentationCode component in use.
Sorry, I read the PresentationCore.dll version from the VS2008 "add reference" dialog, what actually gets copied to the bin/debug folder is
PresentationCore.dll
File/Product version: 3.0.6920.1500
Last date modified: 11/24/2008 @ 6:34pm.
- Can you post a sample of your code that you're using? Also, can you make sure that your code is single threaded (in C# [STAThread] in front of your Main method).
- TEST CODE:
using System;
using System.IO;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Text;
namespace TestCreatorContactInfo
{
class Program
{
[STAThread]
static void Main(string[] args)
{
string myImageFilename = "1010E000840_BOYONSTEP.jpg";
Console.WriteLine( "CreatorContactInformation extracted from \"{0}\"", myImageFilename );
Console.WriteLine( "====================================================================" );
try
{
using (Stream myFileStream = File.Open( myImageFilename, FileMode.Open ))
{
BitmapDecoder myDecoder = BitmapDecoder.Create( myFileStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.None );
BitmapMetadata myMetadata = myDecoder.Frames[0].Metadata as BitmapMetadata;
Console.WriteLine( "myCreatorCiAdrExtadr: {0}", myMetadata.GetQuery( "/xmp/CreatorContactInfo/CiAdrExtadr" ) as string );
Console.WriteLine( "myCreatorCiAdrCity: {0}", myMetadata.GetQuery( "/xmp/CreatorContactInfo/CiAdrCity" ) as string );
Console.WriteLine( "myCreatorCiAdrRegion: {0}", myMetadata.GetQuery( "/xmp/CreatorContactInfo/CiAdrRegion" ) as string );
Console.WriteLine( "myCreatorCiAdrPcode: {0}", myMetadata.GetQuery( "/xmp/CreatorContactInfo/CiAdrPcode" ) as string );
Console.WriteLine( "myCreatorCiAdrCtry: {0}", myMetadata.GetQuery( "/xmp/CreatorContactInfo/CiAdrCtry" ) as string );
Console.WriteLine( "myCreatorCiTelWork: {0}", myMetadata.GetQuery( "/xmp/CreatorContactInfo/CiTelWork" ) as string );
Console.WriteLine( "myCreatorCiEmailWork: {0}", myMetadata.GetQuery( "/xmp/CreatorContactInfo/CiEmailWork" ) as string );
Console.WriteLine( "myCreatorCiUrlWork: {0}", myMetadata.GetQuery( "/xmp/CreatorContactInfo/CiUrlWork" ) as string );
}
}
catch (Exception e)
{
Console.WriteLine( "Exception: {0}", e.Message );
Console.WriteLine( "Exception Type: {0}", e.GetType() );
Console.WriteLine( "Source: {0}", e.Source );
Console.WriteLine( "Stack Trace: {0}", e.StackTrace );
}
}
}
}
CONSOLE OUTPUT:
CreatorContactInformation extracted from "1010E000840_BOYONSTEP.jpg"
====================================================================
Exception: Unexpected type of metadata.
Exception Type: System.IO.FileFormatException
Source: PresentationCore
Stack Trace: at System.Windows.Media.Imaging.BitmapMetadata.GetQuery(String query)
at TestCreatorContactInfo.Program.Main(String[] args) in Program.cs:line 24
ACTUAL IMAGE EMBEDDED XMP PACKET (personally identifiable information "sanitized" and whitespace packet padding at end removed):
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.1-c036 46.276720, Mon Feb 19 2007 22:13:43 ">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="" xmlns:tiff="http://ns.adobe.com/tiff/1.0/" xmlns:exif="http://ns.adobe.com/exif/1.0/" xmlns:xap="http://ns.adobe.com/xap/1.0/" xmlns:aux="http://ns.adobe.com/exif/1.0/aux/" xmlns:crs="http://ns.adobe.com/camera-raw-settings/1.0/" xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xapMM="http://ns.adobe.com/xap/1.0/mm/" xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" xmlns:ppmd="http://ns.Picade.com/ppmd/1.0/" xmlns:xapRights="http://ns.adobe.com/xap/1.0/rights/" xmlns:illustrator="http://ns.adobe.com/illustrator/1.0/" xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/" tiff:Make="NIKON CORPORATION" tiff:Model="NIKON D300" tiff:XResolution="3000000/10000" tiff:YResolution="3000000/10000" tiff:ResolutionUnit="2" tiff:Orientation="1" 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;DE6C4CA9AF0C290A39CEC64DC0CB958D" tiff:ImageWidth="5213" tiff:ImageLength="3424" tiff:Compression="1" tiff:PhotometricInterpretation="2" tiff:SamplesPerPixel="3" tiff:PlanarConfiguration="1" exif:ExifVersion="0221" exif:ExposureTime="1/125" exif:ShutterSpeedValue="6965784/1000000" exif:FNumber="8/1" exif:ApertureValue="6/1" exif:ExposureProgram="1" exif:DateTimeOriginal="2008-10-14T17:34:48.83-04:00" exif:DateTimeDigitized="2008-10-14T17:34:48.83-04:00" exif:ExposureBiasValue="0/6" exif:MaxApertureValue="36/10" exif:MeteringMode="3" exif:LightSource="0" exif:FocalLength="180/10" exif:SensingMethod="2" exif:FileSource="3" exif:SceneType="1" exif:FocalLengthIn35mmFilm="27" exif:CustomRendered="0" exif:ExposureMode="1" exif:WhiteBalance="0" exif:SceneCaptureType="0" exif:GainControl="0" exif:Contrast="0" exif:Saturation="0" exif:Sharpness="0" exif:SubjectDistanceRange="0" exif:DigitalZoomRatio="1/1" exif:PixelXDimension="5213" exif:PixelYDimension="3424" exif:ColorSpace="-1" 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;23CEE8C8E4033F8A2722D4EFCD6F404B" xap:ModifyDate="2009-02-06T21:45:58-05:00" xap:CreateDate="2009-02-06T15:40:10-05:00" xap:CreatorTool="Adobe Photoshop CS3 Macintosh" xap:Rating="0" xap:MetadataDate="2009-02-06T21:45:58-05:00" aux:SerialNumber="99999999" aux:LensInfo="180/10 2000/10 35/10 56/10" aux:Lens="18.0-200.0 mm f/3.5-5.6" aux:ImageNumber="9968" crs:RawFileName="_BDP9965.NEF" crs:Version="4.5" crs:WhiteBalance="As Shot" crs:Temperature="5950" crs:Tint="+13" crs:Exposure="0.00" crs:Shadows="5" crs:Brightness="+50" crs:Contrast="+25" crs:Saturation="0" crs:Sharpness="25" crs:LuminanceSmoothing="0" crs:ColorNoiseReduction="25" crs:ChromaticAberrationR="0" crs:ChromaticAberrationB="0" crs:VignetteAmount="0" crs:ShadowTint="0" crs:RedHue="0" crs:RedSaturation="0" crs:GreenHue="0" crs:GreenSaturation="0" crs:BlueHue="0" crs:BlueSaturation="0" crs:FillLight="0" crs:Vibrance="0" crs:HighlightRecovery="0" crs:Clarity="0" crs:Defringe="0" crs:HueAdjustmentRed="0" crs:HueAdjustmentOrange="0" crs:HueAdjustmentYellow="0" crs:HueAdjustmentGreen="0" crs:HueAdjustmentAqua="0" crs:HueAdjustmentBlue="0" crs:HueAdjustmentPurple="0" crs:HueAdjustmentMagenta="0" crs:SaturationAdjustmentRed="0" crs:SaturationAdjustmentOrange="0" crs:SaturationAdjustmentYellow="0" crs:SaturationAdjustmentGreen="0" crs:SaturationAdjustmentAqua="0" crs:SaturationAdjustmentBlue="0" crs:SaturationAdjustmentPurple="0" crs:SaturationAdjustmentMagenta="0" crs:LuminanceAdjustmentRed="0" crs:LuminanceAdjustmentOrange="0" crs:LuminanceAdjustmentYellow="0" crs:LuminanceAdjustmentGreen="0" crs:LuminanceAdjustmentAqua="0" crs:LuminanceAdjustmentBlue="0" crs:LuminanceAdjustmentPurple="0" crs:LuminanceAdjustmentMagenta="0" crs:SplitToningShadowHue="0" crs:SplitToningShadowSaturation="0" crs:SplitToningHighlightHue="0" crs:SplitToningHighlightSaturation="0" crs:SplitToningBalance="0" crs:ParametricShadows="0" crs:ParametricDarks="0" crs:ParametricLights="0" crs:ParametricHighlights="0" crs:ParametricShadowSplit="25" crs:ParametricMidtoneSplit="50" crs:ParametricHighlightSplit="75" crs:SharpenRadius="+1.0" crs:SharpenDetail="25" crs:SharpenEdgeMasking="0" crs:PostCropVignetteAmount="0" crs:ConvertToGrayscale="False" crs:ToneCurveName="Medium Contrast" crs:CameraProfile="ACR 4.4" crs:CameraProfileDigest="F3ECC1496F73CCB1E2CCA8DCD725018D" crs:HasSettings="True" crs:HasCrop="False" crs:AlreadyApplied="True" photoshop:SidecarForExtension="NEF" photoshop:ColorMode="3" photoshop:ICCProfile="Adobe RGB (1998)" photoshop:CaptionWriter="Photographer_Name" photoshop:AuthorsPosition="photographer" photoshop:Credit="Photographer_Name / Picade" photoshop:Country="United States" photoshop:State="New Jersey" photoshop:History="2009-02-05T16:58:05-05:00	File james on front steps.tif saved
2009-02-06T18:38:03-05:00	File 1010E000840_BOYONSTEP.jpg opened
2009-02-06T21:45:58-05:00	File 1010E000840_BOYONSTEP.jpg closed
2009-02-06T21:45:58-05:00	File 1010E000840_BOYONSTEP.jpg saved
" dc:format="image/jpeg" xapMM:InstanceID="uuid:71E28F8AF52A11DDBBBAA626058CE75C" xapMM:DocumentID="uuid:9C77E39AF51111DDBBBAA626058CE75C" ppmd:ppmd_prop5="Unspecified" ppmd:ppmd_prop3="Model Released" ppmd:ppmd_prop2="Exclusive" ppmd:ppmd_prop0="Photographer_Name" ppmd:ppmd_prop1="99999" ppmd:ppmd_prop4="0029" xapRights:Marked="True" xapRights:WebStatement="http://www.picade.com/CopyrightNotice.html" illustrator:StartupProfile="Print" Iptc4xmpCore:CountryCode="US">
<tiff:BitsPerSample>
<rdf:Seq>
<rdf:li>8</rdf:li>
<rdf:li>8</rdf:li>
<rdf:li>8</rdf:li>
</rdf:Seq>
</tiff:BitsPerSample>
<exif:ISOSpeedRatings>
<rdf:Seq>
<rdf:li>200</rdf:li>
</rdf:Seq>
</exif:ISOSpeedRatings>
<exif:Flash exif:Fired="False" exif:Return="0" exif:Mode="0" exif:Function="False" exif:RedEyeMode="False"/>
<crs:ToneCurve>
<rdf:Seq>
<rdf:li>0, 0</rdf:li>
<rdf:li>32, 22</rdf:li>
<rdf:li>64, 56</rdf:li>
<rdf:li>128, 128</rdf:li>
<rdf:li>192, 196</rdf:li>
<rdf:li>255, 255</rdf:li>
</rdf:Seq>
</crs:ToneCurve>
<dc:rights>
<rdf:Alt>
<rdf:li xml:lang="x-default">Copyright © Photographer_Name / Picade. All rights reserved worldwide</rdf:li>
</rdf:Alt>
</dc:rights>
<dc:creator>
<rdf:Seq>
<rdf:li>Photographer_Name</rdf:li>
</rdf:Seq>
</dc:creator>
<dc:title>
<rdf:Alt>
<rdf:li xml:lang="x-default">1010E000840_BOYONSTEP</rdf:li>
</rdf:Alt>
</dc:title>
<dc:subject>
<rdf:Bag>
<rdf:li>Photographer_Name</rdf:li>
<rdf:li>house</rdf:li>
<rdf:li>porch</rdf:li>
<rdf:li>steps</rdf:li>
<rdf:li>front</rdf:li>
<rdf:li>in front of</rdf:li>
<rdf:li>blue</rdf:li>
<rdf:li>neighborhood</rdf:li>
<rdf:li>suburbs</rdf:li>
<rdf:li>suburban</rdf:li>
<rdf:li>domestic life</rdf:li>
<rdf:li>home</rdf:li>
<rdf:li>angelic</rdf:li>
<rdf:li>anticipate</rdf:li>
<rdf:li>anticipating</rdf:li>
<rdf:li>ANTICIPATION</rdf:li>
<rdf:li>BOY</rdf:li>
<rdf:li>boys</rdf:li>
<rdf:li>calm</rdf:li>
<rdf:li>CAUCASIAN</rdf:li>
<rdf:li>CHILD</rdf:li>
<rdf:li>CHILDHOOD</rdf:li>
<rdf:li>childish</rdf:li>
<rdf:li>childlike</rdf:li>
<rdf:li>children</rdf:li>
<rdf:li>COLOR</rdf:li>
<rdf:li>colour</rdf:li>
<rdf:li>community</rdf:li>
<rdf:li>contemplating</rdf:li>
<rdf:li>CONTEMPLATION</rdf:li>
<rdf:li>CURIOSITY</rdf:li>
<rdf:li>curious</rdf:li>
<rdf:li>deliberation</rdf:li>
<rdf:li>expectant</rdf:li>
<rdf:li>gazing</rdf:li>
<rdf:li>guileless</rdf:li>
<rdf:li>hope</rdf:li>
<rdf:li>hopeful</rdf:li>
<rdf:li>HORIZONTAL</rdf:li>
<rdf:li>INNOCENCE</rdf:li>
<rdf:li>innocent</rdf:li>
<rdf:li>inquisitive</rdf:li>
<rdf:li>interest</rdf:li>
<rdf:li>kid</rdf:li>
<rdf:li>kids</rdf:li>
<rdf:li>LIFESTYLE</rdf:li>
<rdf:li>looking</rdf:li>
<rdf:li>males</rdf:li>
<rdf:li>musing</rdf:li>
<rdf:li>NEIGHBORHOOD</rdf:li>
<rdf:li>observing</rdf:li>
<rdf:li>ONE</rdf:li>
<rdf:li>outdoors</rdf:li>
<rdf:li>OUTSIDE</rdf:li>
<rdf:li>peaceful</rdf:li>
<rdf:li>SERENE</rdf:li>
<rdf:li>single</rdf:li>
<rdf:li>STANDING</rdf:li>
<rdf:li>thought</rdf:li>
<rdf:li>tranquil</rdf:li>
<rdf:li>tyke</rdf:li>
<rdf:li>WAITING</rdf:li>
<rdf:li>watchful</rdf:li>
<rdf:li>WATCHING</rdf:li>
<rdf:li>wishful</rdf:li>
<rdf:li>wonder</rdf:li>
<rdf:li>young</rdf:li>
<rdf:li>youngster</rdf:li>
<rdf:li>youth</rdf:li>
</rdf:Bag>
</dc:subject>
<dc:description>
<rdf:Alt>
<rdf:li xml:lang="x-default">young boy standing in front of his house</rdf:li>
</rdf:Alt>
</dc:description>
<xapMM:DerivedFrom stRef:instanceID="uuid:3FCA13C3F44711DDBBBAA626058CE75C" stRef:documentID="uuid:0999AA309A4E11DDBE6EA14C067EA235"/>
<xapRights:UsageTerms>
<rdf:Alt>
<rdf:li xml:lang="x-default">Image is copyrighted and registered with US Copyright Office and may not be reproduced or used in any manner without a prior paid license from Photographer_Name and prior payment of the appropriate fee for the license as invoiced by Photographer_Name for the usage. Any reproduction or usage without a license is a violation of copyright and will be litigated to the full extent of the law.</rdf:li>
</rdf:Alt>
</xapRights:UsageTerms>
<Iptc4xmpCore:CreatorContactInfo Iptc4xmpCore:CiAdrExtadr="xxx East xxth St xx" Iptc4xmpCore:CiAdrCity="New York" Iptc4xmpCore:CiAdrRegion="NY" Iptc4xmpCore:CiAdrPcode="10000" Iptc4xmpCore:CiAdrCtry="USA" Iptc4xmpCore:CiTelWork="xxx.xxx.xxx" Iptc4xmpCore:CiEmailWork="nobody@nowhere.com" Iptc4xmpCore:CiUrlWork="www.nowhere.com"/>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end="w"?>- Edited byMichael Beasley Thursday, April 30, 2009 6:11 PM
- Michael, you are missing the final "/" ... /xmp/CreatorContactInfo/CiAdrExtadr/
- The trailing slash in the query you mention is not the problem and is explicitly incorrect itself (and yes I have tested it with a conditional compilation just to be certain, it thows an exception <GGGG>!), the issue is that WIC as currently released for the .Net framework under Vista SP2 apparently does not seem to be able to handle "flattened" XMP as generated by the Adobe XMP Toolkit with versions greater than "3.1.1-112" (ie: Adobe Creative Suite applications with version greater than or equal to 3 like Photoshop CS3+ ), and specifically by version 4 of the Adobe XMP Toolkit or later, which is the majority of the images I am working with.
Hopefully this will get fixed with Win7, but I am not holding my breath!
Some slightly modified source code:
----------------------------------------------------
using System;
using System.IO;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Text;
namespace TestCreatorContactInfo
{
class Program
{
[STAThread]
static void Main(string[] args)
{
// my original test image, created in "Adobe Photoshop CS3 Macintosh",
// metadata written by "Adobe XMP Core 4.1-c036 46.276720, Mon Feb 19 2007 22:13:43"
string myImageFilename = "1010E000840_BOYONSTEP.jpg";
string ProgramName1 = "Adobe Photoshop CS3 Macintosh";
string XmpToolkitVersion1 = "Adobe XMP Core 4.1-c036 46.276720";
// my original test image above with a minor addition to Xmp metadata,
// then saved in "Adobe Photoshop CS2 Windows", xmptk="3.1.1-112"
string myModifiedImageFilename = "1010E000840_BOYONSTEP.cs2.jpg";
string ProgramName2 = "Adobe Photoshop CS2 Windows";
string XmpToolkitVersion2 = "3.1.1-112";
// Sample image by Robert A. Wlodarczyk of Microsoft,
// contained in SampleImages.zip downloaded via
// http://blogs.msdn.com/rwlodarc/archive/2006/03/30/565138.aspx
// created in Adobe Photoshop CS2 Windows, xmptk="3.1.1-111"
// on 2006-03-28T11:23:59-08:00
string MicrosoftWICSampleImage = "sample.jpg";
string ProgramName3 = "Adobe Photoshop CS2 Windows";
string XmpToolkitVersion3 = "3.1.1-111";
// test the images
TestWIC( MicrosoftWICSampleImage, ProgramName3, XmpToolkitVersion3 );
TestWIC( myModifiedImageFilename, ProgramName2, XmpToolkitVersion2 );
TestWIC( myImageFilename, ProgramName1, XmpToolkitVersion1 );
Console.WriteLine( "Press any key to exit ..." );
Console.ReadKey();
}
static void TestWIC( string theImagePathname, string theProgramName, string theXmpToolkitVersion )
{
Console.WriteLine();
Console.WriteLine( "====================================================================" );
Console.WriteLine( "CreatorContactInfo extracted from \"{0}\"", theImagePathname );
Console.WriteLine( "Image created by \"{0}\"", theProgramName );
Console.WriteLine( "Adobe XMP toolkit version \"{0}\"", theXmpToolkitVersion );
Console.WriteLine( "====================================================================" );
try
{
using (Stream myFileStream = File.Open( theImagePathname, FileMode.Open ))
{
BitmapDecoder myDecoder = BitmapDecoder.Create( myFileStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.None );
BitmapMetadata myMetadata = myDecoder.Frames[0].Metadata as BitmapMetadata;
// this GetQuery() succeeds and returns expected data
Console.WriteLine( "dc.Creator: {0}", myMetadata.GetQuery( "/xmp/dc:creator/{ulong=0}" ) as string );
// these GetQuery()'s always throw exceptions for images with CreatorContactInfo metadata
// written by the Adobe SDK XmpToolkit versions > 4:
// Exception: Unexpected type of metadata.
// Exception Type: System.IO.FileFormatException
// Source: PresentationCore
// Source of CreatorContactInfo query string is a blog post by Bob Wlodarczyk
// at http://blogs.msdn.com/rwlodarc/archive/2006/03/30/565138.aspx
#if Test_jendxb
// this throws an exception:
// Exception: Unexpected type of metadata.
// Exception Type: System.IO.FileFormatException
// Source: PresentationCore
// Stack Trace: at System.Windows.Media.Imaging.BitmapMetadata.GetQuery(String query)
// at TestCreatorContactInfo.Program.TestWIC(String theImagePathname, String theProgramName, String theXmpToolkitVersion) in E:\ProgramDevelopment\ImageMetadata\TestCreatorContactInfo\Program.cs:line 76
Console.WriteLine( "CreatorCiAdrExtadr: {0}", myMetadata.GetQuery( "/xmp/CreatorContactInfo/CiAdrExtadr/" ) as string );
#else
Console.WriteLine( "CreatorCiAdrExtadr: {0}", myMetadata.GetQuery( "/xmp/CreatorContactInfo/CiAdrExtadr" ) as string );
#endif
Console.WriteLine( "CreatorCiAdrCity: {0}", myMetadata.GetQuery( "/xmp/CreatorContactInfo/CiAdrCity" ) as string );
Console.WriteLine( "CreatorCiAdrRegion: {0}", myMetadata.GetQuery( "/xmp/CreatorContactInfo/CiAdrRegion" ) as string );
Console.WriteLine( "CreatorCiAdrPcode: {0}", myMetadata.GetQuery( "/xmp/CreatorContactInfo/CiAdrPcode" ) as string );
Console.WriteLine( "CreatorCiAdrCtry: {0}", myMetadata.GetQuery( "/xmp/CreatorContactInfo/CiAdrCtry" ) as string );
Console.WriteLine( "CreatorCiTelWork: {0}", myMetadata.GetQuery( "/xmp/CreatorContactInfo/CiTelWork" ) as string );
Console.WriteLine( "CreatorCiEmailWork: {0}", myMetadata.GetQuery( "/xmp/CreatorContactInfo/CiEmailWork" ) as string );
Console.WriteLine( "CreatorCiUrlWork: {0}", myMetadata.GetQuery( "/xmp/CreatorContactInfo/CiUrlWork" ) as string );
}
}
catch (Exception e)
{
Console.WriteLine( "********************************************************************" );
Console.WriteLine( "Exception: {0}", e.Message );
Console.WriteLine( "Exception Type: {0}", e.GetType() );
Console.WriteLine( "Source: {0}", e.Source );
Console.WriteLine( "Stack Trace: {0}", e.StackTrace );
Console.WriteLine( "********************************************************************" );
}
}
}
}
----------------------------------------------------
Which generates NOT USING the conditional compilation:
----------------------------------------------------
====================================================================
CreatorContactInfo extracted from "sample.jpg"
Image created by "Adobe Photoshop CS2 Windows"
Adobe XMP toolkit version "3.1.1-111"
====================================================================
dc.Creator: Robert A. Wlodarczyk
CreatorCiAdrExtadr: 1 Microsoft Way
CreatorCiAdrCity: Redmond
CreatorCiAdrRegion: WA
CreatorCiAdrPcode: 98052
CreatorCiAdrCtry: USA
CreatorCiTelWork:
CreatorCiEmailWork:
CreatorCiUrlWork:
====================================================================
CreatorContactInfo extracted from "1010E000840_BOYONSTEP.cs2.jpg"
Image created by "Adobe Photoshop CS2 Windows"
Adobe XMP toolkit version "3.1.1-112"
====================================================================
dc.Creator: Photographer_Name
CreatorCiAdrExtadr: xxx East xxth St xx
CreatorCiAdrCity: New York
CreatorCiAdrRegion: NY
CreatorCiAdrPcode: 10000
CreatorCiAdrCtry: USA
CreatorCiTelWork: xxx.xxx.xxx
CreatorCiEmailWork: nobody@nowhere.com
CreatorCiUrlWork: www.nowhere.com
====================================================================
CreatorContactInfo extracted from "1010E000840_BOYONSTEP.jpg"
Image created by "Adobe Photoshop CS3 Macintosh"
Adobe XMP toolkit version "Adobe XMP Core 4.1-c036 46.276720"
====================================================================
dc.Creator: Photographer_Name
********************************************************************
Exception: Unexpected type of metadata.
Exception Type: System.IO.FileFormatException
Source: PresentationCore
Stack Trace: at System.Windows.Media.Imaging.BitmapMetadata.GetQuery(String query)
at TestCreatorContactInfo.Program.TestWIC(String theImagePathname, String theProgramName, String theXmpToolkitVersion) in E:\ProgramDevelopment\ImageMetadata\TestCreatorContactInfo\Program.cs:line 72
********************************************************************
Press any key to exit ...
----------------------------------------------------
Basically, unless WIC gets fixed to properly support valid, "flattened" XMP as generated by current versions of the Adobe XMP toolkit it is totally unusable for my purposes which require full support of complex structures such as the CreatorContactInfo and PLUS metadata.
As a result, I have had to move my development from using WIC to using the Adobe XMP toolkit with a C# wrapper ... which works flawlessly and supports all forms and variants of XMP metadata I have been able to throw at it.
HTH.
Cordially,
Michael Beasley- Marked As Answer byMichael Beasley Thursday, October 29, 2009 7:26 PM
- Unmarked As Answer byMichael Beasley Thursday, October 29, 2009 7:26 PM
- The release version of the "Platform Update for Windows Vista" shipped via Windows Update yesterday (28 October 2009.
Using the previously compiled application and code referenced immediately above after installing the Platform Update and restarting resulted in getting "Unexpected type of metadata" thrown exceptions for all three test images.
In VS2008 after the update installation and restart, removing the reference to to PresentationCore, re-adding it, then recompiling (and may have only required recompiling - I did not try that first), results in all three test images having their metadata (and specifically the XMP CreatorContactInfo "flattened attribute style" metadata written by the Adobe XMP toolkit version 4) being read correctly for all three images.
Cordially,
Michael Beasley- Marked As Answer byMichael Beasley Thursday, October 29, 2009 7:29 PM


