18

I am using exiv2 to manipulate metadata in a jpeg file. I need to write more information related to image processing into the metadata. Is is possible to create Custom Exif tags other than the standard ones?

Alan W. Smith
  • 24,647
  • 4
  • 70
  • 96
Senan
  • 411
  • 2
  • 6
  • 16

4 Answers4

17

From http://www.exif.org/Exif2-2.PDF:

D. Tags Relating to User Information

MakerNote
A tag for manufacturers of Exif writers to record any desired information. The contents are up to the manufacturer, but this tag should not be used for any other than its intended purpose.
Tag = 37500 (927C.H)
Type = UNDEFINED
Count = Any
Default = none

UserComment
A tag for Exif users to write keywords or comments on the image besides those in ImageDescription, and without the character code limitations of the ImageDescription tag.
Tag = 37510 (9286.H)
Type = UNDEFINED
Count = Any
Default = none

exiv2 supports MakerNote tags: http://dev.exiv2.org/projects/exiv2/wiki/How_to_add_support_for_a_new_makernote

If you don't want to do this, you can use UserComment: http://www.exiv2.org/doc/exifcomment_8cpp-example.html

Peter Bagyinszki
  • 1,069
  • 1
  • 10
  • 29
  • 9
    Thanks Peter. But I really want to know is it possible to define a "custom tag" other than the standard ones – Senan Jun 01 '12 at 04:23
  • It may be safer to encode your data using JSON, YAML, CSV, etc. and store the blob in one of the aforementioned tags. That would also give you more flexibility in case your metadata changes. – Clint Pachl Aug 31 '22 at 03:07
  • Care may need to be taken if using the *MakerNote* as a data store. According to the [Exiv2 developers](https://exiv2.org/makernote.html) regarding this manufacturer's tag, they state, "any change of an Exif tag, which moves the makernote field, will corrupt it." – Clint Pachl Aug 31 '22 at 03:17
3

A better way to have custom metadata is by using Adobe XMP with a custom namespace.

Yoav
  • 5,962
  • 5
  • 39
  • 61
3

Based on my research EXIF tags are conformed to a standard set of tags as described here.

Within the standards document it states (in reference to EXIF tags),

A registration system is used for character codes to avoid duplication. When a character code is registered, a standard document is indicated in the reference column to indicate the character format specification. If a character code is used for which there is no clear specification like Shift-JIS in Japan, Undefined is designated.

Therefore its my understanding that there is a standard set of tags (the registered tags) otherwise when you query it using a tool such as exiftool it will show up as 'Undefined'.

So in order to have a tag that is recognizable by tools or other entities, you'd need to register your tag to become part of the standardized tags.

Randoramma
  • 123
  • 9
1

I did find a way to add custom EXIF tags to files with ExifTool

I had to create a config file for fields I wanted:

%Image::ExifTool::UserDefined = (
'Image::ExifTool::Exif::Main' => {
    0xd001 => {
        Name => 'Category',
        Writable => 'string',
        WriteGroup => 'IFD0',
    },
    0xd002 => {
        Name => 'PhotoID',
        Writable => 'string',
        WriteGroup => 'IFD0',
    },
    # add more user-defined EXIF tags here...
  },
);

Then you can write to the fields using exiftool:

exiftool -config exif.config -EXIF:PhotoID=15 -EXIF:Category=Cars c:\temp\pic.png

To read the EXIF info:

exiftool -config exif.config c:\temp\pic.png
KnuturO
  • 1,565
  • 15
  • 19