Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2006-06-16
2
Medium Priority
?
659 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 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Make the most of your online learning experience.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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 …

618 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