Solved

How do I set/get the Keywords property of a JPG file in Windows XP SP2?

Posted on 2006-06-16
2
613 Views
Last Modified: 2008-03-04
Environment:
Windows XP SP2 (on NTFS)
JPG picture taken from any camera
Any Programming Language

Please verify your answer before submitting it, because JPG files do not behave the same as other file types in Windows XP.

How do I programmatically get and set the Keywords (located on the Summary Tab of the Properties of a JPG file) field on a JPG file?

1. Locate a JPG (example: C:\Pic.jpg)
2. In Windows Explorer, right-click on the file, choose Properties, click on the Summary Tab and examine the "Keywords" field.
3. Type "MyTestKeyword" into the Keywords field and click OK
4. Run your code sample which should read the Keywords property of the file
5. Programmitically change the keyword to "UpdatedKeyWord" and resave the file.
6. Back in Windows Explorer, right-click on the file, choose Properties, click on the Summary Tab and examine the "Keywords" field.  It should read:  "UpdatedKeyWord"


NOTE: DSOFile.DLL has already been tried, and does not work on JPG files, also DocumentSummaryInformation streams on NTFS do not work on JPG files, also EXIF and IPTC Properties do not work because they are not reflected in the Keywords property of the file (through Windows Explorer)
0
Comment
Question by:thebatdude
2 Comments
 
LVL 1

Accepted Solution

by:
spamsickle earned 500 total points
ID: 16928522
Actually, JPEG files behave like other files in XP too.  The problem is that there are keywords, and there are XP keyword.  The keywords you're trying to change are XP keywords.

You said the solution could be in any language, so I'm submitting one I tested that requires Perl.  Assuming you have the Activestate Perl environment installed on your computer, you would need to download and install Phil Harvey's excellent Exiftool from http://www.sno.phy.queensu.ca/~phil/exiftool/.  If you don't have Activestate Perl, you should install that first.

Exiftool has a command-line interface named Exiftool, which is in the root directory of the Exiftool installation.  To execute it under Windows XP to do what you want to do, you would (from the Exiftool directory) issue the command:

perl exiftool "-XPKeywords=MyKeyWord1 MyKeyWord2" "d:\imagefilepath\imagefile.jpg"

The Exiftool installation requires you to ungzip and untar, but there are utilities to do that on Windows too.  I used 7-zip from www.7-zip.org (run it twice, once to ungzip, and again to untar).

I've tested this solution, and it works.  You'll have to do a bit of legwork, but Activestate Perl is a pretty painless installation, and exiftool is worth the effort.
0
 
LVL 1

Author Comment

by:thebatdude
ID: 16935945
Awesome, that was just enough clues to get me to google on XPKeywords and I located the EXIF Tag ID (40095) for this EXIF property, then was able to write some .NET Code to read and set the property based on the EXIF Tag ID.

3 Weeks of my life gone forever on this one.

Thank you for the help!!

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now