Right, so your options here are (since we've completely ruled out any 3rd party code whatsoever):
- Some Delphi guru (which I am certainly not) coming out of the woodwork and illuminating us with the existence of standard Delphi library code which handles this, or,
- You write your own JPEG metadata decoding library.
Since I can't help you with the first option, here are some references you'll need while pursuing the second:
- Wikipedia's JPEG article - one of the better written articles on the wiki. Great introductory material to this hairy subject.
- ITU T.81 - The original JPEG specification. The most important bit is in Annex B, but this actually describes a format known as JIF which isn't actually in use. However, both JFIF and EXIF are based on it.
- ICC - This specifies ICC (International Color Consortium) profiles, which are the bit that seems to be wrong with your headers.
- ICC 2010 - New version of above specification, with Errata.
- JFIF - The format most JPEG files actually use.
- EXIF - Another format JPEG files use, especially those originating from digital cameras.
- ITU T.84 - Less useful, this describes JPEG extensions. I'm including it here for completeness.
Sadly, none of the public domain JPEG implementations that I'm aware of (in any language) actually handle the relevant bits of the standards, namely EXIF and ICC profiles, so I can't give you any code you could draw inspiration from. The best place to look would probably be libexif
, but that's GPL'ed.
What you're going to want to do is to read in the JPEG file as a regular file, parse the input according to information gleaned from the above documents, make the necessary changes, and write it back out. I don't think this is going to be easy, but apparently this is the only solution you'll accept.
Good luck!