├── .gitattributes
├── .gitignore
├── PhotoDeal.sln
├── WindowsFormsApp1
├── App.config
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── WindowsFormsApp1.csproj
└── packages.config
└── 新建文本文档.txt
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Oo]ut/
33 | [Ll]og/
34 | [Ll]ogs/
35 |
36 | # Visual Studio 2015/2017 cache/options directory
37 | .vs/
38 | # Uncomment if you have tasks that create the project's static files in wwwroot
39 | #wwwroot/
40 |
41 | # Visual Studio 2017 auto generated files
42 | Generated\ Files/
43 |
44 | # MSTest test Results
45 | [Tt]est[Rr]esult*/
46 | [Bb]uild[Ll]og.*
47 |
48 | # NUnit
49 | *.VisualState.xml
50 | TestResult.xml
51 | nunit-*.xml
52 |
53 | # Build Results of an ATL Project
54 | [Dd]ebugPS/
55 | [Rr]eleasePS/
56 | dlldata.c
57 |
58 | # Benchmark Results
59 | BenchmarkDotNet.Artifacts/
60 |
61 | # .NET Core
62 | project.lock.json
63 | project.fragment.lock.json
64 | artifacts/
65 |
66 | # ASP.NET Scaffolding
67 | ScaffoldingReadMe.txt
68 |
69 | # StyleCop
70 | StyleCopReport.xml
71 |
72 | # Files built by Visual Studio
73 | *_i.c
74 | *_p.c
75 | *_h.h
76 | *.ilk
77 | *.meta
78 | *.obj
79 | *.iobj
80 | *.pch
81 | *.pdb
82 | *.ipdb
83 | *.pgc
84 | *.pgd
85 | *.rsp
86 | *.sbr
87 | *.tlb
88 | *.tli
89 | *.tlh
90 | *.tmp
91 | *.tmp_proj
92 | *_wpftmp.csproj
93 | *.log
94 | *.vspscc
95 | *.vssscc
96 | .builds
97 | *.pidb
98 | *.svclog
99 | *.scc
100 |
101 | # Chutzpah Test files
102 | _Chutzpah*
103 |
104 | # Visual C++ cache files
105 | ipch/
106 | *.aps
107 | *.ncb
108 | *.opendb
109 | *.opensdf
110 | *.sdf
111 | *.cachefile
112 | *.VC.db
113 | *.VC.VC.opendb
114 |
115 | # Visual Studio profiler
116 | *.psess
117 | *.vsp
118 | *.vspx
119 | *.sap
120 |
121 | # Visual Studio Trace Files
122 | *.e2e
123 |
124 | # TFS 2012 Local Workspace
125 | $tf/
126 |
127 | # Guidance Automation Toolkit
128 | *.gpState
129 |
130 | # ReSharper is a .NET coding add-in
131 | _ReSharper*/
132 | *.[Rr]e[Ss]harper
133 | *.DotSettings.user
134 |
135 | # TeamCity is a build add-in
136 | _TeamCity*
137 |
138 | # DotCover is a Code Coverage Tool
139 | *.dotCover
140 |
141 | # AxoCover is a Code Coverage Tool
142 | .axoCover/*
143 | !.axoCover/settings.json
144 |
145 | # Coverlet is a free, cross platform Code Coverage Tool
146 | coverage*.json
147 | coverage*.xml
148 | coverage*.info
149 |
150 | # Visual Studio code coverage results
151 | *.coverage
152 | *.coveragexml
153 |
154 | # NCrunch
155 | _NCrunch_*
156 | .*crunch*.local.xml
157 | nCrunchTemp_*
158 |
159 | # MightyMoose
160 | *.mm.*
161 | AutoTest.Net/
162 |
163 | # Web workbench (sass)
164 | .sass-cache/
165 |
166 | # Installshield output folder
167 | [Ee]xpress/
168 |
169 | # DocProject is a documentation generator add-in
170 | DocProject/buildhelp/
171 | DocProject/Help/*.HxT
172 | DocProject/Help/*.HxC
173 | DocProject/Help/*.hhc
174 | DocProject/Help/*.hhk
175 | DocProject/Help/*.hhp
176 | DocProject/Help/Html2
177 | DocProject/Help/html
178 |
179 | # Click-Once directory
180 | publish/
181 |
182 | # Publish Web Output
183 | *.[Pp]ublish.xml
184 | *.azurePubxml
185 | # Note: Comment the next line if you want to checkin your web deploy settings,
186 | # but database connection strings (with potential passwords) will be unencrypted
187 | *.pubxml
188 | *.publishproj
189 |
190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
191 | # checkin your Azure Web App publish settings, but sensitive information contained
192 | # in these scripts will be unencrypted
193 | PublishScripts/
194 |
195 | # NuGet Packages
196 | *.nupkg
197 | # NuGet Symbol Packages
198 | *.snupkg
199 | # The packages folder can be ignored because of Package Restore
200 | **/[Pp]ackages/*
201 | # except build/, which is used as an MSBuild target.
202 | !**/[Pp]ackages/build/
203 | # Uncomment if necessary however generally it will be regenerated when needed
204 | #!**/[Pp]ackages/repositories.config
205 | # NuGet v3's project.json files produces more ignorable files
206 | *.nuget.props
207 | *.nuget.targets
208 |
209 | # Microsoft Azure Build Output
210 | csx/
211 | *.build.csdef
212 |
213 | # Microsoft Azure Emulator
214 | ecf/
215 | rcf/
216 |
217 | # Windows Store app package directories and files
218 | AppPackages/
219 | BundleArtifacts/
220 | Package.StoreAssociation.xml
221 | _pkginfo.txt
222 | *.appx
223 | *.appxbundle
224 | *.appxupload
225 |
226 | # Visual Studio cache files
227 | # files ending in .cache can be ignored
228 | *.[Cc]ache
229 | # but keep track of directories ending in .cache
230 | !?*.[Cc]ache/
231 |
232 | # Others
233 | ClientBin/
234 | ~$*
235 | *~
236 | *.dbmdl
237 | *.dbproj.schemaview
238 | *.jfm
239 | *.pfx
240 | *.publishsettings
241 | orleans.codegen.cs
242 |
243 | # Including strong name files can present a security risk
244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
245 | #*.snk
246 |
247 | # Since there are multiple workflows, uncomment next line to ignore bower_components
248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
249 | #bower_components/
250 |
251 | # RIA/Silverlight projects
252 | Generated_Code/
253 |
254 | # Backup & report files from converting an old project file
255 | # to a newer Visual Studio version. Backup files are not needed,
256 | # because we have git ;-)
257 | _UpgradeReport_Files/
258 | Backup*/
259 | UpgradeLog*.XML
260 | UpgradeLog*.htm
261 | ServiceFabricBackup/
262 | *.rptproj.bak
263 |
264 | # SQL Server files
265 | *.mdf
266 | *.ldf
267 | *.ndf
268 |
269 | # Business Intelligence projects
270 | *.rdl.data
271 | *.bim.layout
272 | *.bim_*.settings
273 | *.rptproj.rsuser
274 | *- [Bb]ackup.rdl
275 | *- [Bb]ackup ([0-9]).rdl
276 | *- [Bb]ackup ([0-9][0-9]).rdl
277 |
278 | # Microsoft Fakes
279 | FakesAssemblies/
280 |
281 | # GhostDoc plugin setting file
282 | *.GhostDoc.xml
283 |
284 | # Node.js Tools for Visual Studio
285 | .ntvs_analysis.dat
286 | node_modules/
287 |
288 | # Visual Studio 6 build log
289 | *.plg
290 |
291 | # Visual Studio 6 workspace options file
292 | *.opt
293 |
294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
295 | *.vbw
296 |
297 | # Visual Studio LightSwitch build output
298 | **/*.HTMLClient/GeneratedArtifacts
299 | **/*.DesktopClient/GeneratedArtifacts
300 | **/*.DesktopClient/ModelManifest.xml
301 | **/*.Server/GeneratedArtifacts
302 | **/*.Server/ModelManifest.xml
303 | _Pvt_Extensions
304 |
305 | # Paket dependency manager
306 | .paket/paket.exe
307 | paket-files/
308 |
309 | # FAKE - F# Make
310 | .fake/
311 |
312 | # CodeRush personal settings
313 | .cr/personal
314 |
315 | # Python Tools for Visual Studio (PTVS)
316 | __pycache__/
317 | *.pyc
318 |
319 | # Cake - Uncomment if you are using it
320 | # tools/**
321 | # !tools/packages.config
322 |
323 | # Tabs Studio
324 | *.tss
325 |
326 | # Telerik's JustMock configuration file
327 | *.jmconfig
328 |
329 | # BizTalk build output
330 | *.btp.cs
331 | *.btm.cs
332 | *.odx.cs
333 | *.xsd.cs
334 |
335 | # OpenCover UI analysis results
336 | OpenCover/
337 |
338 | # Azure Stream Analytics local run output
339 | ASALocalRun/
340 |
341 | # MSBuild Binary and Structured Log
342 | *.binlog
343 |
344 | # NVidia Nsight GPU debugger configuration file
345 | *.nvuser
346 |
347 | # MFractors (Xamarin productivity tool) working folder
348 | .mfractor/
349 |
350 | # Local History for Visual Studio
351 | .localhistory/
352 |
353 | # BeatPulse healthcheck temp database
354 | healthchecksdb
355 |
356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
357 | MigrationBackup/
358 |
359 | # Ionide (cross platform F# VS Code tools) working folder
360 | .ionide/
361 |
362 | # Fody - auto-generated XML schema
363 | FodyWeavers.xsd
--------------------------------------------------------------------------------
/PhotoDeal.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.3.32804.467
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsFormsApp1", "WindowsFormsApp1\WindowsFormsApp1.csproj", "{E73BEB2C-68FC-4D6B-888E-E7F9F57C7463}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {E73BEB2C-68FC-4D6B-888E-E7F9F57C7463}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {E73BEB2C-68FC-4D6B-888E-E7F9F57C7463}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {E73BEB2C-68FC-4D6B-888E-E7F9F57C7463}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {E73BEB2C-68FC-4D6B-888E-E7F9F57C7463}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {BC8AEC0D-7C02-4CB6-BFC5-791CC2D9365C}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/WindowsFormsApp1/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/WindowsFormsApp1/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsFormsApp1
2 | {
3 | partial class Form1
4 | {
5 | ///
6 | /// 必需的设计器变量。
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// 清理所有正在使用的资源。
12 | ///
13 | /// 如果应释放托管资源,为 true;否则为 false。
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows 窗体设计器生成的代码
24 |
25 | ///
26 | /// 设计器支持所需的方法 - 不要修改
27 | /// 使用代码编辑器修改此方法的内容。
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
32 | this.txtPhotoPath = new System.Windows.Forms.TextBox();
33 | this.label1 = new System.Windows.Forms.Label();
34 | this.btnPhotoPath = new System.Windows.Forms.Button();
35 | this.comboBox1 = new System.Windows.Forms.ComboBox();
36 | this.button1 = new System.Windows.Forms.Button();
37 | this.label2 = new System.Windows.Forms.Label();
38 | this.label3 = new System.Windows.Forms.Label();
39 | this.label4 = new System.Windows.Forms.Label();
40 | this.SuspendLayout();
41 | //
42 | // txtPhotoPath
43 | //
44 | this.txtPhotoPath.Location = new System.Drawing.Point(94, 12);
45 | this.txtPhotoPath.Name = "txtPhotoPath";
46 | this.txtPhotoPath.ReadOnly = true;
47 | this.txtPhotoPath.Size = new System.Drawing.Size(385, 21);
48 | this.txtPhotoPath.TabIndex = 0;
49 | //
50 | // label1
51 | //
52 | this.label1.AutoSize = true;
53 | this.label1.Location = new System.Drawing.Point(11, 15);
54 | this.label1.Name = "label1";
55 | this.label1.Size = new System.Drawing.Size(77, 12);
56 | this.label1.TabIndex = 1;
57 | this.label1.Text = "照片路径选择";
58 | //
59 | // btnPhotoPath
60 | //
61 | this.btnPhotoPath.Location = new System.Drawing.Point(500, 12);
62 | this.btnPhotoPath.Name = "btnPhotoPath";
63 | this.btnPhotoPath.Size = new System.Drawing.Size(75, 23);
64 | this.btnPhotoPath.TabIndex = 2;
65 | this.btnPhotoPath.Text = "浏览...";
66 | this.btnPhotoPath.UseVisualStyleBackColor = true;
67 | this.btnPhotoPath.Click += new System.EventHandler(this.btnPhotoPath_Click);
68 | //
69 | // comboBox1
70 | //
71 | this.comboBox1.FormattingEnabled = true;
72 | this.comboBox1.Items.AddRange(new object[] {
73 | "yyyyMMdd - HH_mm",
74 | "yyyyMMdd - HH_mm_ss"});
75 | this.comboBox1.Location = new System.Drawing.Point(94, 39);
76 | this.comboBox1.Name = "comboBox1";
77 | this.comboBox1.Size = new System.Drawing.Size(155, 20);
78 | this.comboBox1.TabIndex = 3;
79 | this.comboBox1.TextChanged += new System.EventHandler(this.comboBox1_TextChanged);
80 | this.comboBox1.Validated += new System.EventHandler(this.comboBox1_Validated);
81 | //
82 | // button1
83 | //
84 | this.button1.Location = new System.Drawing.Point(500, 41);
85 | this.button1.Name = "button1";
86 | this.button1.Size = new System.Drawing.Size(75, 23);
87 | this.button1.TabIndex = 4;
88 | this.button1.Text = "执行";
89 | this.button1.UseVisualStyleBackColor = true;
90 | this.button1.Click += new System.EventHandler(this.button1_Click_1);
91 | //
92 | // label2
93 | //
94 | this.label2.AutoSize = true;
95 | this.label2.Location = new System.Drawing.Point(11, 44);
96 | this.label2.Name = "label2";
97 | this.label2.Size = new System.Drawing.Size(77, 12);
98 | this.label2.TabIndex = 5;
99 | this.label2.Text = "日期格式选择";
100 | //
101 | // label3
102 | //
103 | this.label3.AutoSize = true;
104 | this.label3.Location = new System.Drawing.Point(255, 42);
105 | this.label3.Name = "label3";
106 | this.label3.Size = new System.Drawing.Size(41, 12);
107 | this.label3.TabIndex = 6;
108 | this.label3.Text = "效果:";
109 | //
110 | // label4
111 | //
112 | this.label4.AutoSize = true;
113 | this.label4.Location = new System.Drawing.Point(293, 41);
114 | this.label4.Name = "label4";
115 | this.label4.Size = new System.Drawing.Size(29, 12);
116 | this.label4.TabIndex = 7;
117 | this.label4.Text = "XXXX";
118 | //
119 | // Form1
120 | //
121 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
122 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
123 | this.ClientSize = new System.Drawing.Size(593, 78);
124 | this.Controls.Add(this.label4);
125 | this.Controls.Add(this.label3);
126 | this.Controls.Add(this.label2);
127 | this.Controls.Add(this.button1);
128 | this.Controls.Add(this.comboBox1);
129 | this.Controls.Add(this.btnPhotoPath);
130 | this.Controls.Add(this.label1);
131 | this.Controls.Add(this.txtPhotoPath);
132 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
133 | this.MaximizeBox = false;
134 | this.MinimizeBox = false;
135 | this.Name = "Form1";
136 | this.Text = "照片处理器";
137 | this.Load += new System.EventHandler(this.Form1_Load);
138 | this.ResumeLayout(false);
139 | this.PerformLayout();
140 |
141 | }
142 |
143 | #endregion
144 |
145 | private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
146 | private System.Windows.Forms.TextBox txtPhotoPath;
147 | private System.Windows.Forms.Label label1;
148 | private System.Windows.Forms.Button btnPhotoPath;
149 | private System.Windows.Forms.ComboBox comboBox1;
150 | private System.Windows.Forms.Button button1;
151 | private System.Windows.Forms.Label label2;
152 | private System.Windows.Forms.Label label3;
153 | private System.Windows.Forms.Label label4;
154 | }
155 | }
156 |
157 |
--------------------------------------------------------------------------------
/WindowsFormsApp1/Form1.cs:
--------------------------------------------------------------------------------
1 | using MetadataExtractor;
2 | using MetadataExtractor.Formats.Exif;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.ComponentModel;
6 | using System.Data;
7 | using System.Drawing;
8 | using System.Drawing.Imaging;
9 | using System.Globalization;
10 | using System.IO;
11 | using System.Linq;
12 | using System.Text;
13 | using System.Text.RegularExpressions;
14 | using System.Threading.Tasks;
15 | using System.Windows.Forms;
16 | using static System.Net.WebRequestMethods;
17 | using static System.Windows.Forms.VisualStyles.VisualStyleElement;
18 | using Directory = System.IO.Directory;
19 | using File = System.IO.File;
20 |
21 | namespace WindowsFormsApp1
22 | {
23 | public partial class Form1 : Form
24 | {
25 | public Form1()
26 | {
27 | InitializeComponent();
28 | filter = "图像文件(JPeg, Gif, Bmp, etc.)|*.jpg;*.jpeg;*.gif;*.bmp;*.tif; *.tiff; *.png| JPeg 图像文件(*.jpg;*.jpeg)"
29 | + "|*.jpg;*.jpeg |GIF 图像文件(*.gif)|*.gif |BMP图像文件(*.bmp)|*.bmp|Tiff图像文件(*.tif;*.tiff)|*.tif;*.tiff|Png图像文件(*.png)"
30 | + "| *.png |所有文件(*.*)|*.*"
31 | + "|*.mp4";
32 | this.comboBox1.SelectedIndex = 0;
33 | }
34 |
35 | private void Form1_Load(object sender, EventArgs e)
36 | {
37 |
38 | }
39 |
40 | private void button1_Click(object sender, EventArgs e)
41 | {
42 | string str = SelectImg();
43 | ChangePhotoNameByPhotoInfo(str);
44 | //var lines = from directory in directories
45 | // from tag in directory.Tags
46 | // select $"{directory.Name}: {tag.TagName} = {tag.Description}";
47 |
48 | //foreach (var line in lines)
49 | // Console.WriteLine(line);
50 | }
51 |
52 | private static void ChangePhotoNameByPhotoInfo(string str)
53 | {
54 | if (Path.GetExtension(str).Equals(".mp4"))
55 | {
56 |
57 | };
58 | if (filter.Contains(Path.GetExtension(str)))
59 | {
60 | var directories = ImageMetadataReader.ReadMetadata(str);
61 |
62 | var lines = from directory in directories
63 | from tag in directory.Tags
64 | //select $"{directory.Name}: {tag.TagName} = {tag.Description}";
65 | select new { tag.Name, tag.Description };
66 | //var dd = directories.OfType().FirstOrDefault()?.Tags?.FirstOrDefault(t => (t.Name.Equals("Date/Time")))?.Description;
67 | if (lines != null)
68 | {
69 | string dd = "";
70 | DateTime dt = DateTime.MinValue;
71 | if (Path.GetExtension(str).Equals(".mp4"))
72 | {
73 | dd = lines.FirstOrDefault(t => t.Name.Equals("Created"))?.Description;
74 | Match match = Regex.Match(dd, @"\d{1}月 \d{2} \d{2}:\d{2}:\d{2}:\d{2} \d{4}");
75 | dd = dd.Substring(2);
76 | //dd = match.Value;
77 | if (!string.IsNullOrEmpty(dd))
78 | dt = DateTime.ParseExact(dd, " M月 dd HH:mm:ss yyyy", CultureInfo.CurrentCulture);
79 | }
80 | else
81 | {
82 | dd = lines.FirstOrDefault(t => t.Name.Equals("Date/Time"))?.Description;
83 | if(!string.IsNullOrEmpty(dd))
84 | dt = DateTime.ParseExact(dd, "yyyy:MM:dd HH:mm:ss", CultureInfo.CurrentCulture);
85 | else
86 | {
87 |
88 | }
89 | }
90 | if (dt != DateTime.MinValue)
91 | {
92 | CreatePhoto(dt, str);
93 | }
94 | }
95 | }
96 | }
97 |
98 | private void button2_Click(object sender, EventArgs e)
99 | {
100 | //this.listBox1.Items.Clear();
101 | //string str = SelectImg();
102 | //if (str != "")
103 | //{
104 | // this.listBox1.Items.Add(str);
105 | // Image image = GetImage(str);
106 | // this.pictureBox1.BackgroundImage = image;
107 | // List list = GetImageInfo(str, image);
108 | // foreach (var item in list)
109 | // {
110 | // listBox1.Items.Add(item);
111 | // }
112 |
113 | //}
114 | }
115 |
116 | private void btnSelectImg1_Click(object sender, EventArgs e)
117 | {
118 | //string str = SelectImg();
119 | //if (str != "")
120 | //{
121 | // txtImg1.Text = str;
122 | // pbImg1.BackgroundImage = GetImage(str);
123 | // List list = GetImageInfo(str, pbImg1.BackgroundImage);
124 | // txtMsg.Clear();
125 | // foreach (var item in list)
126 | // {
127 | // txtMsg.AppendText("\n" + item);
128 | // }
129 |
130 | //}
131 | }
132 |
133 | private List GetImageInfo(string path, Image image)
134 | {
135 | List list = new List();
136 |
137 | PropertyItem[] pt = image.PropertyItems;
138 | for (int i = 0; i < pt.Length; i++)
139 | {
140 |
141 | PropertyItem p = pt[i];
142 | switch (pt[i].Id)
143 |
144 | { // 设备制造商 20.
145 |
146 | case 0x010F:
147 | {
148 | string str = System.Text.ASCIIEncoding.ASCII.GetString(pt[i].Value);
149 | list.Add("设备制造商:" + str);
150 | }
151 | break;
152 |
153 | case 0x0110: // 设备型号 25.
154 |
155 | {
156 | string str = GetValueOfType2(p.Value);
157 | list.Add("设备型号:" + str);
158 | }
159 | break;
160 |
161 | case 0x0132: // 拍照时间 30.
162 | {
163 | string str = GetValueOfType2(p.Value);
164 | list.Add("拍照时间:" + str);
165 | }
166 | break;
167 |
168 | case 0x829A: // .曝光时间
169 | {
170 | string str = GetValueOfType5(p.Value);
171 | list.Add("曝光时间:" + str);
172 | }
173 | break;
174 |
175 | case 0x8827: // ISO 40.
176 | {
177 | string str = GetValueOfType3(p.Value);
178 | list.Add("ISO:" + str);
179 | }
180 |
181 | break;
182 |
183 | case 0x010E: // 图像说明info.description
184 | {
185 | string str = GetValueOfType2(p.Value);
186 | list.Add("图像说明:" + str);
187 | }
188 | break;
189 |
190 | case 0x920a: //相片的焦距
191 |
192 | {
193 | string str = GetValueOfType5A(p.Value) + " mm";
194 | list.Add("焦距值:" + str);
195 | }
196 | break;
197 |
198 | case 0x829D: //相片的光圈值
199 | {
200 | string str = GetValueOfType5A(p.Value);
201 | list.Add("光圈值:" + str);
202 | }
203 | break;
204 |
205 | default:
206 | {
207 |
208 | }
209 | break;
210 |
211 | }
212 |
213 | }
214 | return list;
215 | }
216 |
217 | public string GetValueOfType2(byte[] b)// 对type=2 的value值进行读取
218 | {
219 | return System.Text.Encoding.ASCII.GetString(b);
220 | }
221 |
222 | private static string GetValueOfType3(byte[] b) //对type=3 的value值进行读取
223 | {
224 | if (b.Length != 2) return "unknow";
225 | return Convert.ToUInt16(b[1] << 8 | b[0]).ToString();
226 | }
227 |
228 | private static string GetValueOfType5(byte[] b) //对type=5 的value值进行读取
229 | {
230 | if (b.Length != 8) return "unknow";
231 | UInt32 fm, fz;
232 | fm = 0;
233 | fz = 0;
234 | fz = Convert.ToUInt32(b[7] << 24 | b[6] << 16 | b[5] << 8 | b[4]);
235 | fm = Convert.ToUInt32(b[3] << 24 | b[2] << 16 | b[1] << 8 | b[0]);
236 | return fm.ToString() + "/" + fz.ToString() + " sec";
237 |
238 | }
239 |
240 | private static string GetValueOfType5A(byte[] b)//获取光圈的值
241 | {
242 | if (b.Length != 8) return "unknow";
243 | UInt32 fm, fz;
244 | fm = 0;
245 | fz = 0;
246 | fz = Convert.ToUInt32(b[7] << 24 | b[6] << 16 | b[5] << 8 | b[4]);
247 | fm = Convert.ToUInt32(b[3] << 24 | b[2] << 16 | b[1] << 8 | b[0]);
248 | double temp = (double)fm / fz;
249 | return (temp).ToString();
250 | }
251 | static string filter = "";
252 | public string SelectImg()
253 | {
254 | OpenFileDialog openFi = new OpenFileDialog();
255 | openFi.Filter = filter;
256 | if (openFi.ShowDialog() == DialogResult.OK)
257 | {
258 | return openFi.FileName;
259 | }
260 | return "";
261 | }
262 |
263 | ///
264 | /// 用内存流来读取图片
265 | ///
266 | ///
267 | ///
268 | public static Image GetImage(string filePath)
269 | {
270 | Image image = null;
271 | try
272 | {
273 | //实例化一个文件流
274 | using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
275 | {
276 | //把文件读取到字节数组
277 | byte[] data = new byte[fs.Length];
278 | fs.Read(data, 0, data.Length);
279 | image = Image.FromStream(new MemoryStream(data));
280 | fs.Close();
281 | }
282 | }
283 | catch (Exception ex)
284 | {
285 | MessageBox.Show(ex.ToString());
286 | }
287 | return image;
288 | }
289 |
290 | private void btnPhotoPath_Click(object sender, EventArgs e)
291 | {
292 | string s = this.txtPhotoPath.Text;
293 | if(string.IsNullOrEmpty(s))
294 | s = Directory.GetCurrentDirectory();
295 | this.folderBrowserDialog1.SelectedPath = s;
296 |
297 | if(this.folderBrowserDialog1.ShowDialog() == DialogResult.OK)
298 | {
299 | this.txtPhotoPath.Text = this.folderBrowserDialog1.SelectedPath;
300 | }
301 | }
302 |
303 | System.IO.FileInfo[] GetAllFileInfo2(System.IO.DirectoryInfo dir)
304 | {
305 | return dir.GetFiles(".", System.IO.SearchOption.AllDirectories);
306 |
307 | }
308 | private void button1_Click_1(object sender, EventArgs e)
309 | {
310 | System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(this.txtPhotoPath.Text);
311 | //#region 调用端(类库的方法)
312 | System.IO.FileInfo[] allFiles = GetAllFileInfo2(dir);
313 | foreach (var item in allFiles)
314 | {
315 | ChangePhotoNameByPhotoInfo(item.FullName);
316 | }
317 | //foreach (System.IO.FileInfo file in allFiles)
318 | //{
319 | // //MessageBox.Show(file.Name);
320 | // Match match = Regex.Match(file.Name, @"\d{4}_\d{2}_\d{2}_\d{2}_\d{2}");
321 | // string date = match.Value;
322 |
323 | // //Regex reg = new Regex("(?.*?)", RegexOptions.CultureInvariant);
324 |
325 | // //foreach (Match m in reg.Matches(file.Name))
326 | // //{
327 | // // string sdate = m.Groups["date"].Value;
328 | // // sdate = sdate.Replace("年", "-").Replace("月", "-").Replace("日", "").Replace(".", "-");
329 | // // DateTime dt = System.DateTime.Now;
330 |
331 |
332 | // // //符合日期规范
333 | // // if (DateTime.TryParse(sdate, out dt)) { }
334 |
335 | // //}
336 | // //MessageBox.Show(date.ToString());
337 | // DateTime dt = DateTime.ParseExact(date, "yyyy_MM_dd_HH_mm", CultureInfo.CurrentCulture);
338 | // string dealFullName = file.FullName;
339 | // CreatePhoto(dt, dealFullName);
340 | //}
341 | //#endregion
342 |
343 | }
344 |
345 | private static void CreatePhoto(DateTime dt, string dealFullName)
346 | {
347 | string s = dt.ToString("yyyyMMdd - HH_mm");
348 | string sPath = /*Path.Combine(*/Path.GetDirectoryName(dealFullName)/*, "处理好的图片")*/;
349 | if (!Directory.Exists(sPath))
350 | Directory.CreateDirectory(sPath);
351 | string sFullName = Path.Combine(sPath, s + Path.GetExtension(dealFullName));
352 | int num = 1;
353 | bool addSS = true;
354 | while (File.Exists(sFullName))
355 | {
356 | if (addSS)
357 | {
358 | sFullName = Path.Combine(sPath, s + "_" + dt.Second.ToString("00") + Path.GetExtension(dealFullName));
359 | addSS = false;
360 | }
361 | else
362 | {
363 | sFullName = Path.Combine(sPath, s + "_" + (num++).ToString("00") + Path.GetExtension(dealFullName));
364 | }
365 | }
366 | File.Move(dealFullName, sFullName);
367 | File.SetCreationTime(sFullName, dt);
368 | }
369 |
370 | private void button2_Click_1(object sender, EventArgs e)
371 | {
372 | button1_Click(sender,e);
373 | }
374 |
375 | private void comboBox1_Validated(object sender, EventArgs e)
376 | {
377 | try
378 | {
379 | label4.Text = DateTime.Now.ToString(this.comboBox1.Text);
380 | }
381 | catch
382 | {
383 |
384 | }
385 | }
386 |
387 | private void comboBox1_TextChanged(object sender, EventArgs e)
388 | {
389 | try
390 | {
391 | label4.Text = DateTime.Now.ToString(this.comboBox1.Text);
392 | }
393 | catch
394 | {
395 |
396 | }
397 | }
398 | }
399 | }
400 |
--------------------------------------------------------------------------------
/WindowsFormsApp1/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 17, 17
122 |
123 |
--------------------------------------------------------------------------------
/WindowsFormsApp1/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace WindowsFormsApp1
8 | {
9 | internal static class Program
10 | {
11 | ///
12 | /// 应用程序的主入口点。
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new Form1());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/WindowsFormsApp1/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("WindowsFormsApp1")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("MicroSoft")]
12 | [assembly: AssemblyProduct("WindowsFormsApp1")]
13 | [assembly: AssemblyCopyright("Copyright © MicroSoft 2022")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("e73beb2c-68fc-4d6b-888e-e7f9f57c7463")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/WindowsFormsApp1/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本: 4.0.30319.42000
5 | //
6 | // 对此文件的更改可能导致不正确的行为,如果
7 | // 重新生成代码,则所做更改将丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace WindowsFormsApp1.Properties
12 | {
13 |
14 |
15 | ///
16 | /// 强类型资源类,用于查找本地化字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// 返回此类使用的缓存 ResourceManager 实例。
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WindowsFormsApp1.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// 重写当前线程的 CurrentUICulture 属性,对
56 | /// 使用此强类型资源类的所有资源查找执行重写。
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/WindowsFormsApp1/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/WindowsFormsApp1/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace WindowsFormsApp1.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/WindowsFormsApp1/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/WindowsFormsApp1/WindowsFormsApp1.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {E73BEB2C-68FC-4D6B-888E-E7F9F57C7463}
8 | WinExe
9 | WindowsFormsApp1
10 | WindowsFormsApp1
11 | v4.7.2
12 | 512
13 | true
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 | ..\packages\MetadataExtractor.2.7.2\lib\net45\MetadataExtractor.dll
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | ..\packages\XmpCore.6.1.10.1\lib\net35\XmpCore.dll
52 |
53 |
54 |
55 |
56 | Form
57 |
58 |
59 | Form1.cs
60 |
61 |
62 |
63 |
64 | Form1.cs
65 |
66 |
67 | ResXFileCodeGenerator
68 | Resources.Designer.cs
69 | Designer
70 |
71 |
72 | True
73 | Resources.resx
74 |
75 |
76 |
77 | SettingsSingleFileGenerator
78 | Settings.Designer.cs
79 |
80 |
81 | True
82 | Settings.settings
83 | True
84 |
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/WindowsFormsApp1/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/新建文本文档.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dream9898123/PhotoDeal/90577c9e0914c683a8a4debf6f6670dac3039590/新建文本文档.txt
--------------------------------------------------------------------------------