зеркало из https://github.com/mono/exiv2-sharp.git
IptcSample
svn path=/trunk/exiv2-sharp/; revision=129572
This commit is contained in:
Родитель
d6e9b36836
Коммит
d40730c7f6
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* IptcSample: some tests using Iptc
|
||||
*
|
||||
* Author(s):
|
||||
* Stephane Delcroix <stephane@delcroix.org>
|
||||
* Mike Gemuende <mike@gemuende.de>
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -24,11 +24,14 @@ 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]);
|
||||
|
||||
foreach (string file in args) {
|
||||
Console.WriteLine ("File {0}", file);
|
||||
Exiv2.Image image = Exiv2.ImageFactory.Open (file);
|
||||
image.ReadMetadata ();
|
||||
|
||||
Console.WriteLine (image.Good);
|
||||
|
@ -42,6 +45,8 @@ namespace Sample
|
|||
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);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче