PHP - How to store data inside a JPG Image

ok, so I have a JPG image, I want to be able to store data inside this image... like a description or somthing... how would go about storing this data inside the image so I can read / set it using PHP?

If I have more data (not just a description) where / how can I store that data in the image ?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roger BaklundCommented:
There is a standard php function for this, called iptcembed(). It is not very easy to use, but there are third party libraries which can be used.

Download IPCT.php and use code like this:
$img = new Image_IPTC('photo\P6170096.JPG');
// write caption
$img->setTag('caption','Description of the image.');
// read caption
echo $img->getTag('caption');  # outputs 'Description of the image.'

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JoshWegenerAuthor Commented:
Aww, I love this... Thanks!

I take it this only works for JPG ? What about PNG ? or TIFF ? BMP ?
Roger BaklundCommented:
No, only jpeg.
JoshWegenerAuthor Commented:
When I look at the code (IPTC.php) - it appears you can only use predefined tags... is this true? or can you add your own to that list?
Roger BaklundCommented:
To maintain compatibillity with other software, you must use predefined tags. But for your own usage, you could create custom tags.

Note that IPTC as such is not limited to jpeg, but this particular function is.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.