views:

1734

answers:

8

How can I write some information inside a photo file like jpg or gif without destroying the image? and of course without showing it on the photo since the whole idea is to send information in the file of photo undetected by anyone (to provide security/privacy to some extent)!

A: 

check this class as well for info: http://www.phpclasses.org/browse/package/3312.html

dusoft
Nice php class!
MAK
+1  A: 

You can store some information in image metadata. In fact that's how man digital cameras 'tag' the photos their making (camera model, date and time, GPS coords etc.).

This data format is called EXIF (Exchangeable Image File Format). There are a lot of examples how to use it in programming languages. Here's the example in Java.

If you want to prevent users from reading this data you can encrypt them somehow, but they will always be able to remove it from your picture (by opening in Photoshop and using Save As for example).

RaYell
So "Save As" in PhotoShop would remove any metadata? Do you know a software that would allow editing it?
MAK
I think photoshop will rewrite this data with it's own data. I think there are plenty EXIF editors, for example I found freeware Quick EXIF Editor http://www.photo-freeware.net/quick-exif-editor.php
RaYell
Great! Anything for Mac?
MAK
This answer (while good) doesnt relate to the question. Exif doesnt hide information. Exif is metadata, not steganography.
Guillaume
"Guillaume" is there other place in the photo file where you can hide data in?
MAK
Yes, if you want to hide data in a photo, have a look at the answers talking about steganography. The first 2 answers (for the moment) are very good.
Guillaume
This doesn't really "hide" information. It's stored in the file in plain text. Numerous graphics programs will read and display it.
Jay
A: 

You can put additional information in the header of the image as meta-data.

Exiv2 is a command line tool / C++ library to do just that (with various file formats).

Sam
+4  A: 

Here is a way to hide an info in jpegs.

This process is called Steganography - hiding (as opposite to encrypting) something where no one expects it to be there.

Here is an example in .net.

Can't find anymore - but somewhere was even better ready to use app written in .NET which could hide information through multiple media files (including audio/video) and even guard it with one or multiple keys.

Arnis L.
+4  A: 

Steghide is the software you need.

Steghide is a steganography program that is able to hide data in various kinds of image- and audio-files.

You can also check a list of steganography tools here.

jeje
+2  A: 

You can concatenate a gif and a zip (the information you want to hide) into one file. Gifs are read from the start of the file, while zips are read from the end of the file.

To create such a file in linux:

$ cat file1.gif >> outfile
$ cat file2.zip >> outfile

The resulting file should have the size of file1.gif and file2.zip together and should be openable by any gif viewer and zip file handler.

crazymaik
Probably the easiest way to hide information :)But how do you retrieve it?
Burkhard
as i said, you can open the resulting file (outfile) with any standard archiver that can handle zip files and extract the information.
crazymaik
Ups. I only read the first part. I'll try the zip part later.
Burkhard
+1 for epic format knowledge win.
bowenl2
+4  A: 

I'm sure there are many ways. Here's one:

In a photograph, minor variations in color would often be unnoticable to the naked eye, or even if noticed, might easily be mistaken for flaws in the quality of the picture.

So to take a simple example, suppose you had a gray-scale GIF image where the pallette is arranged in order from white to black with a smooth range of grays in between. I'm not sure how much you know about graphic file formats, but in GIF you have one byte per pixel, with each possible byte value mapping to some specific color. So in this case we could say pallette #0=RGB(0,0,0), pallette #1=RGB(1,1,1), ... palette #255=RGB(255,255,255).

Then you take an ordinary, real photograph. Break your secret message into individual bits. Set the last bit of each pallette index number to successive bits of your message.

For example, suppose the first eight pixels of the original photo are, say, 01 00 C9 FF FF C8 42 43. Your message begins with the letter "C", ascii code 0110 0111. So you change the last bit of the first byte to 0, changing the byte from 01 to 00. You change the last bit of the second byte to 1, changing the byte from 00 to 01. You change the last bit of the third byte to 1. It's already 1, so that makes no difference. Etc. You end up with the coded 8 bytes being 00 01 C9 FE FF C9 43 43.

The changes to the colors would be so subtle that it's unlikely that anyone looking at the picture would notice. Even if they did notice, unless they had a reason to be suspicious, they would likely just conclude that the picture was of less-than-perfect quality.

Of course nothing says you have to use 1 bit per byte for the secret message. Depending on how much degradation in quality you think you can get away with, you could use 2 bits per byte, or just change 1 bit in every other byte, etc.

Of course the same technique can be used with color photos: change the last bit in each of the RGB components to encode 3 bits per pixel, etc.

Jay
A: 

I wrote this article about hiding information in images, hope you find this useful.

http://cs.temp3.net/page7/page16/page16.html

Mike