説明:
外部 DLL を使用せずに、画像の EXIF / メタデータ / ファイル情報を編集して保存するにはどうすればよいですか?
計画:
個人用のアプリを作成して、個人の Web サイトでホストしている黙示録的な量の画像の名前を変更し、タグを付け直して、整理しています。私は数年間面白い写真などを集めてきたので、ファイルの命名規則に本当の韻や理由はありません. したがって、Image0001.jpg の名前をわかりやすいファイル名に変更し、メタデータ フィールドに入力する必要があります。
目的のプロセスは、既存の jpg、gif、png、tiff、または bmp を取得し、次のことを行います。
- イメージをメモリにロードする
- 必要に応じて bmp ファイルを jpg に変換します (ほとんどの場合、ファイル サイズを小さくするため)。
- 画像タグを ImageData 構造体に読み込みます (以下を参照)
- ファイルデータを ImageData 構造体に読み込みます (必要な場合)
- ユーザーが編集するための画像とタグを表示します (画像ボックスといくつかのテキスト ボックス内)。
- フィールドの編集とファイルの名前変更を許可する
- 変更を画像ファイルに書き込む
- 次のファイルに移動します。
例:
- Image0001.jpg を読み込みます。ImageData 構造フィールドに入力します。
- 説明に「lolcat 天井の猫が息子を送る」と入力します。
- ImageData.FileName を「lolcat-ceiling-cat-sends-son.jpg」に変更。
- ImageData.Name, .Keywords, .Title, .Subject, .Comments を「lolcat 天井の猫が息子を送る」に変更。
- 新しいファイル名でファイルを保存し、すべての新しいタグ フィールドを保存します。
(Later, I will also be using SQL to build a referential database with links to the online copies of these files to allow for searching by keywords, subject, filename, etc, but that's another layer that's much easier than this one. At least to me.)
Problem:
So far, several days of research have yielded almost no measurable progress. Information has apparently been inexplicably hidden behind a bunch of unexpected search keywords that I have not though to use for my searches. Any help would be appreciated.
Current Code as is:
Imports System.IO
Imports System.IO.Path
Imports System.Drawing.Imaging
Imports ImageData '(The Custom Structure below)'
'*Also has a project level reference to the dso.dll referenced below.'
Public Structure ImageData
Shared FileAuthorAuthor As String
Shared FileAuthorCategory As String
Shared FileAuthorComments As String
Shared FileAuthorCompany As String
Shared FileAuthorDateCreated As DateTime
Shared FileAuthorDescription As String
Shared FileAuthorHeight As Decimal
Shared FileAuthorHeightResolution As Decimal
Shared FileAuthorImage As Image
Shared FileAuthorKeywords As String
Shared FileAuthorName As String
Shared FileAuthorPath As String 'URL or IRL'
Shared FileAuthorRead As Boolean
Shared FileAuthorSubject As String
Shared FileAuthorTitle As String
Shared FileAuthorType As String
Shared FileAuthorWidth As Decimal
Shared FileAuthorWidthResolution As Decimal
End Structure 'ImageData
And the current method for finding the data is:
Shared Function ReadExistingData(ByRef FileWithPath As String) As Boolean
'Extract the FileName'
Dim PathParts As String() = FileWithPath.Split("\") '"
Dim FileName As String = PathParts(PathParts.Length - 1)
Dim FileParts As String() = FileName.Split(".")
Dim FileType As String = FileParts(FileParts.Length - 1)
'Create an Image object. '
Dim SelectedImage As Bitmap = New Bitmap(FileWithPath)
'Get the File Info from the Image.'
Dim ImageFileInfo As New FileInfo(FileWithPath)
Dim dso As DSOFile.OleDocumentProperties
dso = New DSOFile.OleDocumentProperties
dso.Open(FileWithPath.Trim, True, DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIfNoWriteAccess)
ImageData.FileAuthor = dso.SummaryProperties.Author '* Requires dso.DLL'
ImageData.FileCategory = dso.SummaryProperties.Category '* Requires dso.DLL'
ImageData.FileComments = dso.SummaryProperties.Comments '* Requires dso.DLL'
ImageData.FileCompany = dso.SummaryProperties.Company '* Requires dso.DLL'
ImageData.FileDateCreated = ImageFileInfo.CreationTime
ImageData.FileDescription = dso.SummaryProperties.Comments '* Requires dso.DLL.'
ImageData.FileHeight = SelectedImage.Height
ImageData.FileHeightResolution = SelectedImage.VerticalResolution
ImageData.FileImage = New Bitmap(FileWithPath)
ImageData.FileKeywords = dso.SummaryProperties.Keywords '* Requires dso.DLL'
ImageData.FileName = FileName
ImageData.FilePath = FileWithPath
ImageData.FileRead = ImageFileInfo.IsReadOnly
ImageData.FileSubject = dso.SummaryProperties.Subject '* Requires dso.DLL'
ImageData.FileTitle = dso.SummaryProperties.Title '* Requires dso.DLL'
ImageData.FileType = FileType
ImageData.FileWidth = SelectedImage.Width
ImageData.FileWidthResolution = SelectedImage.HorizontalResolution
Return True
End Function 'ReadExistingData'
Just a couple of the "Top Box" search hits I've reviewed:
The dso.DLL: Very Helpful, but undesirable. Requires external DLL.
[http://]www.developerfusion.com/code/5093/retrieving-the-summary-properties-of-a-file/不完全なデータ ~ 私の質問に答えません
[http://]msdn.microsoft.com/en-us/library/xddt0dz7.aspx外部 DLL が必要
[http://]www.codeproject.com/KB/GDI-plus/ImageInfo.aspx外部ソフトウェアが必要
[http://]stackoverflow.com/questions/3313474/write-metadata-to-png-image-in-net古いデータ ~ Visual Studio 2005 および .NET 2.0
[http://]www.codeproject.com/KB/graphics/MetaDataAccess.aspxBMP に変換: 便利
そう [http://]www.freevbcode.com/ShowCode.Asp?ID=5799