How do I edit JPG File Title, Subject, Comments, and Tags/Keywords?

点点圈 提交于 2019-12-22 08:47:49

问题


How do I edit JPG File Title, Subject, Comments, and Tags/Keyowrds?*

I have already tried asking this question here:

The Exif information provided was helpful, but in the end did not actually solve the real riddle I was working on. So I'll take another angle at describing the desired result:

I want my VB.NET app to allow me to edit the following details of a Jfile (see image):

Title, Subject, Comments, and Tags/Keyowrds

  • I had a handy image to include but not enough points to post it. Weak.

  • RIGHT CLICK A .JPG IN WINDOWS and select PROPERTIES

  • Win XP: Select the "Summary Tab" and Look at the "Description" group
  • Win7/Server 2008R2: "Details Tab" and look at "Description" group

Can anyone explain how to edit those fields through VB.net in Visual Studio?

EDIT:

The ultimate goal is to use the image viewer/editer that I built, to sort thousands of images of random webjunk I have collected over the years. Upon viewing the image (say "00001.jpg") and figureing out what it is ("ceiling cat sends son" picture of a lol cat), I want to type in the description (already done in the form). When I hit enter I want to rename the file (from "00001.jpg" to "ceiling-cat-sends-son.jpg", then fill in the keywords, title, subject, and comments fields with the same data: "ceiling cat sends son".

This will help with local indexing and with my (later) automating a SQL server referential database for use with site wide searches on my website. The ONLY thing I can't seem to figure out is how to modify those four fields as if I had right-clicked the file and added the keywords.


回答1:


I can only offer you a starting point, since I don't use VB.Net and I only read EXIF data. In C#, if you open file in a System.Drawing.Image instance using:

Image image = System.Drawing.Image.FromFile("path/to/file.jpg");

You can access the raw EXIF data by using image.GetPropertyItem(0x0112), where the list of all available property items are listed here:

http://msdn.microsoft.com/en-us/library/ms534418%28VS.85%29.aspx

Likewise, there's an image.SetPropertyItem(0x0112) method, but I think that will only set it in memory and you will have to save a copy of the image in order to write it out. I think what you want though is the ability to modify the EXIF without touching the actual image, which I do not know how to do.

Using metadata

As I've said in my comment, I recommend that instead of editing the image header information, you should create a Media class that holds that kind of information:

public class Media
{
    public string Title { get; set; }
    public string Subject { get; set; }
    public string Comments { get; set; }
    public string[] Tags { get; set; }
    public string PathToFile { get; set; }
}

Then you would store this record in the database, which makes it really easy to search on. If you need the actual file, use the PathToFile property to locate it.



来源:https://stackoverflow.com/questions/4882130/how-do-i-edit-jpg-file-title-subject-comments-and-tags-keywords

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!