Ooer.com by Chris Neale

Steganography With GD

To save the image simply right click to save it in a browser, or save the image using the optional parameters in imagepng(). Note: You cannot use imagejpeg() to create your image as the jpeg process loses the information hiding our message.

<?php
header
("Content-Type: image/png");
imagepng($output);
?>

Now that we have our hidden image we can save it and send it to our friends.


But what do they do with it once they receive it? Well, they would have to run it through a script that reverses the hiding process and outputs the decoded message image.

<?php
$s
= imagecreatefrompng("hidden.png");
$output = imagecreatetruecolor(imagesx($s),imagesy($s));
for (
$x=0;$x<imagesx($s);$x++) {
    for (
$y=0;$y<imagesy($s);$y++) {
        
$rgb=imagecolorat($s,$x,$y);
        
$r=(((($rgb>>16)&0xFF)&1)==1)?0:255;
        
$g=(((($rgb>>8)&0xFF)&1)==1)?0:255;
        
$b=((($rgb&0xFF)&1)==1)?0:255;
        
$col=imagecolorallocate($output,$r,$g,$b);
        
imagesetpixel($output,$x,$y,$col);
    }
}
header("Content-Type: image/png");
imagepng($output);
?>

Thats all there is to it. Pretty easy stuff. Of course, it would be possible to go much futher. Heres some ideas for extending the script:

* Hide 3 images, one in each colour channel.
* Hide 24 images, eight in each colour channel, one per 'bit'. This would make an image that looked like static.
* Hide a 6bit colour picture using the 2 smallest bits in each channel.
* Hide a repeating watermark in the image, and automatically check it against a database of watermarks to see whose image it is.
Move to page: 1 2 3

Comments

Comments are not currently being accepted for this article.
Sidebar
Published:
21/06/2007
Views:
4440
Author:
Chris Neale
Labels:
Print:
Sidebar:
Wikipedia steganography page
PHP image function reference