Solved

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

Posted on 2006-06-16
2
643 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Monitor input from a computer is usually nothing special.  In this instance it prevented anyone from using the computer.  This was a preconfiguration that didn't work.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Six Sigma Control Plans

691 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