Search code examples
phpcompressiongdsteganography

GD imagejpeg() compression?


I'm working on a project where I edit the pixels of a jpg in PHP using the GD library. Its very crucial and key to my project that the output from PHP retains the pixel values I set (cough-steganography-cough).

This is the first time I've attempted image manipulation in PHP. I've had no problems before in my Java implementations, so I was foolish not to investigate GD's jpeg compression quality before pursuing further.

It turns out that after all my effort, my code does not function the way its supposed to. I am pretty sure it is not my code (tested the encode and decode functions on edited image resources and they worked).

My questions are:

  1. The only problem I can see is with imagejpeg()'s compression. Could I be right?

  2. Are there any libraries that provide the compression that I need?(retain pixel values that I changed)


Solution

  • The JPEG file format is not very suitable for steganography if you do the steganography pixel by pixel.

    JPEG uses an image compression - that even with maximum quality - that will destroy the information on the bit level on each pixel. The jpeg type of compression (lossy compression) is made for the human eye/brain to retain the image but not the bits of the image in the file .

    You need to use an image format that is capable to retain the pixels - as you wrote it already as well. Such a format more likely is BMP with RLE compression or the TIFF image format with ZIP or RLE compression. That's called lossless data compression.