Skip to content

Commit 4f238e6

Browse files
committed
Touch up ParsePhoto program
1 parent 582b05a commit 4f238e6

File tree

2 files changed

+84
-82
lines changed

2 files changed

+84
-82
lines changed

examples/ParsePhoto/ParsePhoto.cs

Lines changed: 0 additions & 82 deletions
This file was deleted.

examples/ParsePhoto/Program.cs

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
using System;
2+
3+
namespace ParsePhoto;
4+
5+
public class Program
6+
{
7+
public static void Main (string [] args)
8+
{
9+
if(args.Length == 0) {
10+
Console.Error.WriteLine("USAGE: mono ParsePhoto.exe PATH [...]");
11+
return;
12+
}
13+
14+
foreach (string path in args)
15+
ParsePhoto (path);
16+
}
17+
18+
static void ParsePhoto (string path)
19+
{
20+
TagLib.File file;
21+
try {
22+
file = TagLib.File.Create(path);
23+
} catch (TagLib.UnsupportedFormatException) {
24+
Console.WriteLine ("UNSUPPORTED FILE: " + path);
25+
Console.WriteLine ();
26+
Console.WriteLine ("---------------------------------------");
27+
Console.WriteLine ();
28+
return;
29+
}
30+
31+
var image = file as TagLib.Image.File;
32+
if (file == null) {
33+
Console.WriteLine ($"NOT AN IMAGE FILE: {path}");
34+
Console.WriteLine ();
35+
Console.WriteLine ("---------------------------------------");
36+
Console.WriteLine ();
37+
return;
38+
}
39+
40+
Console.WriteLine ();
41+
Console.WriteLine (path);
42+
Console.WriteLine ();
43+
44+
Console.WriteLine($"Tags in object : {image.TagTypes}");
45+
Console.WriteLine ();
46+
47+
Console.WriteLine($"Comment : {image.ImageTag.Comment}");
48+
Console.Write("Keywords : ");
49+
foreach (var keyword in image.ImageTag.Keywords) {
50+
Console.Write ($"{keyword} ");
51+
}
52+
53+
Console.WriteLine ();
54+
Console.WriteLine($"Rating : {image.ImageTag.Rating}");
55+
Console.WriteLine($"DateTime : {image.ImageTag.DateTime}");
56+
Console.WriteLine($"Orientation : {image.ImageTag.Orientation}");
57+
Console.WriteLine($"Software : {image.ImageTag.Software}");
58+
Console.WriteLine($"ExposureTime : {image.ImageTag.ExposureTime}");
59+
Console.WriteLine($"FNumber : {image.ImageTag.FNumber}");
60+
Console.WriteLine($"ISOSpeedRatings : {image.ImageTag.ISOSpeedRatings}");
61+
Console.WriteLine($"FocalLength : {image.ImageTag.FocalLength}");
62+
Console.WriteLine($"FocalLength35mm : {image.ImageTag.FocalLengthIn35mmFilm}");
63+
Console.WriteLine($"Make : {image.ImageTag.Make}");
64+
Console.WriteLine($"Model : {image.ImageTag.Model}");
65+
66+
if (image.Properties != null) {
67+
Console.WriteLine($"Width : {image.Properties.PhotoWidth}");
68+
Console.WriteLine($"Height : {image.Properties.PhotoHeight}");
69+
Console.WriteLine($"Type : {image.Properties.Description}");
70+
}
71+
72+
Console.WriteLine ();
73+
Console.WriteLine($"Writable? : {image.Writeable}");
74+
Console.WriteLine($"Corrupt? : {image.PossiblyCorrupt}");
75+
76+
if (image.PossiblyCorrupt) {
77+
foreach (string reason in image.CorruptionReasons) {
78+
Console.WriteLine ($" * {reason}");
79+
}
80+
}
81+
82+
Console.WriteLine ("---------------------------------------");
83+
}
84+
}

0 commit comments

Comments
 (0)