diff --git a/samples/IptcSample.cs b/samples/IptcSample.cs new file mode 100644 index 0000000..8025fdf --- /dev/null +++ b/samples/IptcSample.cs @@ -0,0 +1,56 @@ +/* + * IptcSample: some tests using Iptc + * + * Author(s): + * Stephane Delcroix + * Mike Gemuende + * + * This is free software. See COPYING for details + */ + +using System; +using Exiv2; + +namespace Sample +{ + public class IptcSample + { + static void Main (string [] args) + { + try { + + GLib.GType.Init (); + + GLib.LogFunc logFunc = new GLib.LogFunc (GLib.Log.PrintTraceLogFunction); + GLib.Log.SetLogHandler ("GLib", GLib.LogLevelFlags.Critical, logFunc); + GLib.Log.SetLogHandler ("GLib-GObject", GLib.LogLevelFlags.Critical, logFunc); + GLib.Log.SetLogHandler ("GLib-GObject", GLib.LogLevelFlags.Warning, logFunc); + if (args.Length == 0) { + Console.WriteLine ("Usage: IptcSample.exe [file list]"); + System.Environment.Exit (1); + } + + foreach (string file in args) { + Console.WriteLine ("File {0}", file); + Exiv2.Image image = Exiv2.ImageFactory.Open (file); + image.ReadMetadata (); + + Console.WriteLine (image.Good); + + IptcData iptc_data = image.IptcData; + if (iptc_data.IsEmpty) + Console.WriteLine ("No Iptc data found in file"); + + Console.WriteLine ("Iptc count: {0}", iptc_data.Count); + + foreach (IptcDatum datum in iptc_data) + Console.WriteLine ("{0} {1} {2} {3}", datum.Key, datum.Typename, datum.Count, datum.ToString ()); + } + + + } catch (GLib.GException e) { + Console.WriteLine ("Exiv2.Exception caught {0}", e); + } + } + } +} diff --git a/samples/Makefile.am b/samples/Makefile.am index 7e2d090..9c2c54b 100644 --- a/samples/Makefile.am +++ b/samples/Makefile.am @@ -7,6 +7,7 @@ TARGETS = \ $(builddir)/exifprint \ $(builddir)/XmpSample.exe \ $(builddir)/ImageInfo.exe \ + $(builddir)/IptcSample.exe \ $(builddir)/ExifThumb.exe \ $(builddir)/Previews.exe @@ -36,6 +37,7 @@ EXTRA_DIST = \ ExifComment.cs \ XmpSample.cs \ ImageInfo.cs \ + IptcSample.cs \ ExifThumb.cs \ Previews.cs \ exifprint.c \ @@ -44,6 +46,7 @@ EXTRA_DIST = \ ExifComment \ XmpSample \ ImageInfo \ + IptcSample \ ExifThumb \ Previews diff --git a/samples/Previews.cs b/samples/Previews.cs index afc48f8..94c6e2a 100644 --- a/samples/Previews.cs +++ b/samples/Previews.cs @@ -26,7 +26,7 @@ namespace Sample image.ReadMetadata (); PreviewManager manager = image.PreviewManager; - Console.WriteLine ("manager.PreviewProperties.Count = {0}", manager.PreviewProperties.Count); + //Console.WriteLine ("manager.PreviewProperties.Count = {0}", manager.PreviewProperties.Count); foreach (PreviewProperties prop in manager.PreviewProperties) { Console.WriteLine ("\t t:{0} e:{1} s:{2} w:{3} h:{4}", prop.MimeType, prop.Extension, prop.Size, prop.Width, prop.Height ); PreviewImage prev = manager.GetPreviewImage (prop); diff --git a/samples/XmpSample.cs b/samples/XmpSample.cs index c0f398e..1fe41f2 100644 --- a/samples/XmpSample.cs +++ b/samples/XmpSample.cs @@ -24,24 +24,29 @@ namespace Sample GLib.Log.SetLogHandler ("GLib", GLib.LogLevelFlags.Critical, logFunc); GLib.Log.SetLogHandler ("GLib-GObject", GLib.LogLevelFlags.Critical, logFunc); GLib.Log.SetLogHandler ("GLib-GObject", GLib.LogLevelFlags.Warning, logFunc); - if (args.Length != 1) { - Console.WriteLine ("Usage: XmpSample.exe file"); + if (args.Length == 0) { + Console.WriteLine ("Usage: XmpSample.exe [file list]"); System.Environment.Exit (1); } - Exiv2.Image image = Exiv2.ImageFactory.Open (args [0]); - image.ReadMetadata (); + + foreach (string file in args) { + Console.WriteLine ("File {0}", file); + Exiv2.Image image = Exiv2.ImageFactory.Open (file); + image.ReadMetadata (); - Console.WriteLine (image.Good); + Console.WriteLine (image.Good); - XmpData xmp_data = image.XmpData; - if (xmp_data.IsEmpty) - Console.WriteLine ("No XMP data found in file"); + XmpData xmp_data = image.XmpData; + if (xmp_data.IsEmpty) + Console.WriteLine ("No XMP data found in file"); - Console.WriteLine ("Xmp count: {0}", xmp_data.Count); - - foreach (XmpDatum datum in xmp_data) - Console.WriteLine ("{0} {1} {2} {3}", datum.Key, datum.Typename, datum.Count, datum.ToString ()); + Console.WriteLine ("Xmp count: {0}", xmp_data.Count); + + foreach (XmpDatum datum in xmp_data) + Console.WriteLine ("{0} {1} {2} {3}", datum.Key, datum.Typename, datum.Count, datum.ToString ()); + } + } catch (GLib.GException e) { Console.WriteLine ("Exiv2.Exception caught {0}", e); }