-
-
Notifications
You must be signed in to change notification settings - Fork 699
Expand file tree
/
Copy pathImageInfo.cs
More file actions
116 lines (95 loc) · 3.51 KB
/
ImageInfo.cs
File metadata and controls
116 lines (95 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
ImageGlass Project - Image viewer for Windows
Copyright (C) 2010 - 2026 DUONG DIEU PHAP
Project homepage: https://imageglass.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Cysharp.Text;
using System.Text;
namespace ImageGlass.Base;
public static class ImageInfo
{
public static string? AppName { get; set; } = null;
public static string? Name { get; set; } = null;
public static string? Path { get; set; } = null;
public static string? FileSize { get; set; } = null;
public static string? Dimension { get; set; } = null;
public static string? FrameCount { get; set; } = null;
public static string? ListCount { get; set; } = null;
public static string? Zoom { get; set; } = null;
public static string? ModifiedDateTime { get; set; } = null;
public static string? ExifRating { get; set; } = null;
public static string? ExifDateTime { get; set; } = null;
public static string? ExifDateTimeOriginal { get; set; } = null;
public static string? DateTimeAuto { get; set; } = null;
public static string? ColorSpace { get; set; } = null;
public static string? DPI { get; set; } = null;
public static bool IsNull => AppName == null
&& Name == null
&& Path == null
&& FileSize == null
&& Dimension == null
&& FrameCount == null
&& ListCount == null
&& Zoom == null
&& DateTimeAuto == null
&& ModifiedDateTime == null
&& ExifDateTime == null
&& ExifDateTimeOriginal == null
&& ExifRating == null
&& ColorSpace == null
&& DPI == null;
/// <summary>
/// Gets complete information string in order
/// </summary>
public static string ToString(List<string> infoTags, bool isVirtualImage, string clipboardImageText = "")
{
using var strBuilder = ZString.CreateStringBuilder();
int count = 0;
// remove unsupported tags for virtual image
if (isVirtualImage)
{
ListCount =
Name =
Path =
FileSize =
FrameCount =
ModifiedDateTime =
ExifRating =
ExifDateTime =
ExifDateTimeOriginal =
DateTimeAuto =
ColorSpace =
DPI = null;
if (!string.IsNullOrEmpty(clipboardImageText))
{
strBuilder.Append(clipboardImageText);
count++;
}
}
foreach (var tag in infoTags)
{
// get the property using name
var str = typeof(ImageInfo).GetProperty(tag)?.GetValue(null)?.ToString();
if (!string.IsNullOrEmpty(str))
{
if (count > 0)
{
strBuilder.Append(" ︱ ");
}
strBuilder.Append(str);
count++;
}
}
return strBuilder.ToString();
}
}