123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using ImageMagick;
- using System.Text;
- #if DEBUG
- Console.Write("Debug,Input file path:");
- var filePath = Console.ReadLine();
- #else
- if (args.Length != 1)
- {
- Console.Error.WriteLine("ERR: 1 file required from args");
- return 1;
- }
- var filePath = args[0];
- #endif
- var image = new MagickImage(filePath);
- var parameters = image.GetAttribute("parameters");
- if (parameters != null)
- {
- Console.WriteLine(parameters);
- }
- else
- {
- var x = image.GetExifProfile();
- if (x == null)
- {
- Console.Error.WriteLine("ERR: no exif profile found");
- return 2;
- }
- var p = new ExifProfile(x.ToByteArray()!);
- var v = p.GetValue(ExifTag.UserComment);
- if (v == null)
- {
- Console.Error.WriteLine("ERR: no exif UserComment found");
- return 3;
- }
- var s = Encoding.BigEndianUnicode.GetString(v.Value[8..]);
- Console.WriteLine(s);
- }
- return 0;
|