Alexey Ryazhskikh
Alexey Ryazhskikh

Reputation: 2500

How to store description in jpeg image?

I whant to save image description to jpeg file itself without any external databases or files. I didn't find andy EXIF field for that. Idealy, I want to set description it by imagemagic or same crossplatform tool. What is proper field for it?

Upvotes: 0

Views: 2612

Answers (4)

user3344003
user3344003

Reputation: 21710

There is a JPEG comment tag you could use for this. You could write a simple program to insert comments. The format of the tag is simple and you can insert it into the stream after the header markers.

Upvotes: 0

PhilHarvey
PhilHarvey

Reputation: 946

I think the Exif tag you are looking for is "ImageDescription". You can write this with ExifTool using this command:

exiftool -imagedescription="Some Description" file.jpg

This is a cross-platform tool as you requested, and can read/write many different file and metadata formats.

Upvotes: 0

Mark Setchell
Mark Setchell

Reputation: 208107

You can use jhead to set a comment like this:

jhead -cl "Some funky comment" a.jpg
Modified: a.jpg

Then read it back, also with jhead

jhead a.jpg
File name    : a.jpg
File size    : 787267 bytes
File date    : 2012:02:03 21:02:15
Resolution   : 3492 x 2286
JPEG Quality : 86
Comment      : Some funky comment   <--- HERE IT IS

then check it is visible with ImageMagick's identify too:

identify -verbose a.jpg 

Image: a.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  ...
  ...
  Compression: JPEG
  Quality: 86
  Orientation: Undefined
  Properties:
    comment: Some funky comment              <--- HERE IT IS
    date:create: 2015-01-19T13:47:43+00:00
    date:modify: 2012-02-03T21:02:15+00:00

You can equally set a comment with ImageMagick's mogrify

mogrify -comment "Freddy Frog" a.jpg

and check with jhead

jhead a.jpg
File name    : a.jpg
File size    : 880639 bytes
File date    : 2015:01:19 13:52:51
Resolution   : 3492 x 2286
JPEG Quality : 86
Comment      : Freddy Frog   <--- HERE IT IS

Upvotes: 3

Gerard Rozsavolgyi
Gerard Rozsavolgyi

Reputation: 5074

You can use exiv2 command line on most platforms. You can get all available fields with :

exiv2 -pv img.jpg

You might use Exif.Photo.UserComment for example as a field for description but you can see there a lot of other fields available on the samples here and then use exiv2 -M to change some metadata in your image

Upvotes: 0

Related Questions