As far as I know, JPG is a lossy image compression format
Meanwhile, BMP is a generally uncompressed image format, whose file structure consists of bitmapFileHeader (14 bytes) and bitmapInfoHeader (40 bytes), the rest of which is pixel data.
So I just need to pass the first 54 bytes and store it as a HEADER variable, and store the rest in the PIXELDATA variable.
In this state I can freely encrypt and decrypt PIXELDATA, and can recombine it with HEADER. So that the integrity of the file is maintained.
But in the case of JPG it is different. I'd like to try reading the pixels manually, but I don't know what position the index bytes are in (unlike BMP which skips 54 bytes).
I use Python with various libraries like PIL or Numpy. Both managed to read Pixels, but when saved as a new JPG file, it differed from the original, in that:
- Comparison of SHA-256 checksums.
- Different file sizes.
- Some of the pixel colors change from the original if you look at it in more detail.
My question is, is there another way to read the pixel data of a JPG file but still provide the integrity of the original JPG file when saved in a new JPG file (Same checksum, file sizes, and offcourse the pixel color)?