I have been around the world twice and a half trying to fix a strange issue with a large sum of images I have.
What I need is to know how to read and write the first 4 and 18th bytes in the header of a JPEG file. If they match certain properties, I need to do some certain work and tweak these bytes to reflect something else. I’m basically fixing the format of these pictures to a more standard format, as Delphi doesn’t recognize the format they’re in.
So how do I read/write these bytes? What do I use? I know nothing about reading the raw data of an image file, let alone tweaking it.
NOTE
Deleted most of the question as I had put way too much information from the start.
The mechanics of actually changing the JPG header are very easy. That doesn’t mean fixing the JPG is easy, it’s just that if you know what to change, you can easily do it. Since that’s what you’re asking, here’s how to change the JPG header in-memory, load the modified JPG into a TJpgImage and convert to TBitmap.
Please note I don’t think this is a good approach. Fixing the resulting bitmap is so much easier! See my fresh answer to your other question for how to fix the bitmap here.
And here’s the code you asked for (how to change the JPG header):