1

I have a JPEG file on disk which is not quite normal - this JPEG file has additional rubbish data appended behind End Of Image (FFD9). This JPEG file can still be opened by JPEG viewers though.

I wish to remove those additional information behind End Of Image (FFD9). The constraints are:

  1. Must be done programatically
  2. Must be lossless
  3. Must use native code, e.g. C++

One way I've found out is to re-save the file using IrfanView command-line tool, using lossless JPG_TRANSFORM's command: /jpg_rotate. The additional data behind are automatically stripped off.

However, is there another way in which I can do it in C++ code, If possible, I do not wish to use exes like IrfanView to do it. I wish to do everything in code to keep things lean.

I am thinking of detecting the End Of File (FFD9), then save the buffer before EOF into another JPEG. But, how can I save the buffer losslessly?

Drakosha
  • 11,925
  • 4
  • 39
  • 52
seveleven
  • 697
  • 2
  • 13
  • 21

1 Answers1

3

I guess this is a file handling question and NOT an Image Processing related.

All you need to do write all data till EOF in your Image file into the resultant Image file.

Alphaneo
  • 12,079
  • 22
  • 71
  • 89