Your proposed four step process might seem sensible, but the JPEG step is what is going to break it. Maybe I'm not being clear enough about what "bit fiddling" will do to your image.

Since both JPEG and GIF, and for that matter, PNG are compressed, you cannot modify the bits and expect the image to still be decompressible. The modification must occur before the compression stage, on the bit-map data that is sent to be compressed. You would have the same trouble if you tried to apply your technique to a ZIP file, to "sign it", and when the user tried to decompress this damaged file, it would generate all sorts of CRC errors.

First, GIF and PNG have the property that the image you put in, and the image you get out are identical, bit for bit. GIF is somewhat limited, because you can only have up to 256 colors (8-bit, indexed color) out of a possible 24-bit color space. PNG is better because you can have 16-bit or 24-bit images, but with the same "exact" decompression you'd expect from GIF.

JPEG, on the other hand, always destroys some information in the process of compression. At maximum compression, the image turns into a huge smudge. At minimum compression, it might not look like much, but little 1 or 2 bit variations are eliminated from the image to achieve the compression. The higher the compression, the more the image is an approximation of the original.

Here's a numeric representation of what might occur to an image:
Original GIF JPEG -------- -------- -------- 12141551 12141551 14141551 24140015 24140015 14140014 14140014 14140014 14140014 12230223 12230223 12220222
On the pixel level, the GIF and the original are identical, since there are only 6 different colors used here. The JPEG, though, by virtue of its "lossy" compression, results in a smeared image, where groups of similar pixels are averaged together to achieve compression. The subtle differences between two colors are often eliminated, or approximated using a pattern.

GIF compression works on a bit level, removing redundancy using LZW data compression, the same sort of technique employed by the ZIP program. JPEG uses a more sophisticated form of compression that uses a Fourier transform, or in plain English, a technique that strips out information that is the least relevant. For instance, fine detail in the image is the first to go, and as the compression increases, the amount of detail you get decreases.

A curious thing to note is that JPEG is specifically intended for use with images that are to be seen by the human eye. Since the human eye is not particularly good at distinguishing subtle changes in blue light, the blue in the RGB image is compressed much more than the other two more visible colors. You can see this if you split the image into different channels, such as in Photoshop.

In reply to Re^5: Gif steganography by tadman
in thread Gif steganography by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.