PHP - How to store data inside a JPG Image

Posted on 2008-11-12
Last Modified: 2013-12-13
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 ?
Question by:JoshWegener
    LVL 39

    Accepted Solution

    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

    LVL 1

    Author Comment

    Aww, I love this... Thanks!

    I take it this only works for JPG ? What about PNG ? or TIFF ? BMP ?
    LVL 39

    Expert Comment

    by:Roger Baklund
    No, only jpeg.
    LVL 1

    Author Comment

    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?
    LVL 39

    Expert Comment

    by:Roger Baklund
    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System ( introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
    Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now