5

I'm interested in manually injecting IPTC fields into JPG file on bytes level. JPEG file has multiple metadata segments with respectable size markers. The segments-containers for IPTC are:

App13 - starts with FF ED XX XX ..

8BIM IPTC text metadata - starts with 38 42 49 4D 04 04 00 00 00 00 XX XX ..

IPTC field starts with 1C 02 50 XX XX .. (0x50 = 80, IPTC field #80).

(XX XX = 2 bytes of length-word describing size of mentioned segment data).

Are there any other size markers in JPEG file & metadata to look out for? Do I have to increase their size when appending metadata segment with custom IPTC fields?

How can I add custom metadata field (for example #225) that will work on all JPEG images that already contain IPTC segment?

Working in C# but it's a question about operations on bytes so I guess language doesn't matter.

yosh
  • 3,245
  • 7
  • 55
  • 84
  • I don't understand the question. – onemasse Jun 08 '11 at 21:39
  • @onemasse The question should be clear if you know the construction of JPEG metadata segment on bytes level. Check http://www.codeproject.com/KB/graphics/iptc.aspx – yosh Jun 09 '11 at 08:24
  • 1
    Well, I'm familiar with JPEG and EXIF. Neither EXIF, 8BIM, IPTC or XMP are part of the JPEG standard as I know. So the first sentence simply makes no sence for me. Therefore the confusion. I think I understand your question now. You want to know if there's any other length field you need to adjust. Unless your JPEG is actually an MPO, I don't think so. – onemasse Jun 09 '11 at 08:56
  • @onemasse OK, thanks. I'm actually working on really heavy jpeg files that have all of the above, often even unnecessarily duplicated. – yosh Jun 09 '11 at 09:48

1 Answers1

2

Since nobody replied I'll explain what I did.

ad 1. The file markers I mentioned above are enough to manipulate IPTC.

ad 2. During manual IPTC manipulation on bytes' level you may easily damage file if you accidently remove or overwrite existing bytes, especially if they're markers (headers of some JPEG file part).

ad 3. One has to find and increase App13 and appropriate 8BIM and IPTC markers with the lenght of new metadata field (content size + 5 bytes for IPTC header). So for example to add new field #09 you have to find 8BIM IPTC segment (38 42 49 4D 04 04 00 00 00 00 XX XX) and increase XX XX bytes with new word size. Then increase the wrapping App13 segment (find last FF ED XX XX segment before 8BIM) size and finally at the end of 8BIM (you know the end thanks to the segment lenght bytes) you just add new IPTC field like 1C 02 09 00 05 - adds metadata field #09 of length 5. The following 5 bytes will be considered a field content = the word you add.

Yeah it's a little chaotic but works :-)

yosh
  • 3,245
  • 7
  • 55
  • 84
  • Hi Yosh! Stumbled upon this post after having asked a question about custom metadata for jpegs recently but found no answer. I am interested in adding a custom field as in e.g. "Humidity: 4.5%" the way you propose but not being settled that much in the byte business - could you explain your workaround a bit more, what commands/tools you have used? Thanks a lot! – birgit Mar 20 '12 at 20:36
  • @birgit What you need is more likely XMP metadata. Here I was just concentrating on IPTC, which is closed standard. Here's nice list of IPTC fields: http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/IPTC.html FotoWare Fotostation is quite a good tool to manipulate metadata in images, but currently I'm using my own code to extract it. – yosh Mar 21 '12 at 09:57
  • Great answer. You might be interested/able to answer [this question](http://stackoverflow.com/questions/21743418/adding-8bim-profile-metadata-to-a-tiff-image-file) – crthompson Feb 13 '14 at 06:15