GD imagejpeg () compression?

I am working on a project where I edit jpg pixels in PHP using the GD library. Its very important and the key to my project is that the PHP output saves the pixel values that I set (cough-steganography-cough).

This is the first time I have tried to manipulate images in PHP. I had no problems in Java implementations before, so I was dumb not to investigate the compression quality of GD jpeg before continuing.

It turned out that after my efforts, my code does not work as intended. I am sure that this is not my code (I tested the encoding and decoding functions on the edited image resources, and they worked).

My questions:

  • The only problem I see is imagejpeg() compression. Can i be right

  • Are there any libraries that provide the compression I need? (save the pixel values ​​that I changed)

+4
source share
3 answers

The JPEG file format is not very suitable for steganography if you are steganography pixel by pixel.

JPEG uses image compression - even with the highest quality - it will destroy bit-level information on every pixel. Jpeg compression type ( lossy compression ) is made for the human eye / brain to save the image, but not the image bit in the file.

You need to use an image format that can hold pixels, as you already wrote. This format is more likely to be BMP with RLE compression or TIFF image format with ZIP or RLE compression. This is called lossless compression .

+2
source

By default, the output quality of an image with imagejpeg is 75, try setting it to 100 to get an image with full quality.

  bool imagejpeg ( resource $image [, string $filename [, int $quality ]] ) 

Learn more about manual .

Also try using imagecopyresampled . (I think you would use imagecopyresized somewhere in your code. Use imagecopyresampled instead.)

EDIT

Then I think you should try ImageMagick (or GD2). This gives better quality than GD. Check this

+3
source

Use imagepng() instead of the imagejpeg() function and set the compression value to 0:

bool imagepng ( resource $image [, string $filename [, int $quality [, int $filters ]]] )

See: http://php.net/manual/en/function.imagepng.php

0
source

All Articles