Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7066243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:03:36+00:00 2026-05-28T05:03:36+00:00

I am making a gallery implementation for PHP. The administrator is able to access

  • 0

I am making a gallery implementation for PHP.

The administrator is able to access the upload page, where he would upload and categorize the image. So far so good.

The implementation will allow users to comment on the pictures the admin has uploaded, so I’m implementing a database table to link comments with their respective images.

id | path .:. id | datetime | comment_title | comment_body | uid

So far so good.

I want the administrator to have the ability to rename files (not necessarily via the site, but via FTP or otherwise root access), and not break the whole system.

So I was thinking of implementing a metadata system to link the ID with the image. That would save me both the first table, and will allow free manipulation of the image (both move it inside folders, rename it, etc).

The question is, how do I implement it? How do I write a metadata attached to a file, and how do I read it? Google gave no real results on this one.

If there’s a better way of doing it, I’d love to hear as well!

Will appreciate any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:03:37+00:00Added an answer on May 28, 2026 at 5:03 am

    While I have not used this myself the XMP PHP Toolkit on sourceforge sounds like just what you might be looking for: http://xmpphptoolkit.sourceforge.net/ That being said – it’s in alpha and hasn’t been updated in over a year it appears.

    XMP Toolkit PHP Extension is a PHP module which includes the Adobe XMP
    Toolkit SDK. This PHP5 extension will provide classes and methods to
    manipulate XMP Metadatas from files like jpegs, tiff, png, but also
    wav, mp3, avi, mpeg4, pdf, ai, eps… It’s based from the Adobe XMP
    Toolkit SDK 4.4.2. The goal of this extension is to have php classes
    which can open files, extract metadatas, manipulate them, and put them
    back within few lines of php code. This project is under GPL v3
    License.

    You are also be able to write arbitrary metadata to an image file with iptcembed. As you mention in your comment this only works for JPEG files.

    http://php.net/manual/en/function.iptcembed.php

    Here is a script from the comments of a class that will get and set IPTC data:

    <?
    
        /************************************************************\
    
            IPTC EASY 1.0 - IPTC data manipulator for JPEG images
    
            All reserved www.image-host-script.com
    
            Sep 15, 2008
    
        \************************************************************/
    
        DEFINE('IPTC_OBJECT_NAME', '005');
        DEFINE('IPTC_EDIT_STATUS', '007');
        DEFINE('IPTC_PRIORITY', '010');
        DEFINE('IPTC_CATEGORY', '015');
        DEFINE('IPTC_SUPPLEMENTAL_CATEGORY', '020');
        DEFINE('IPTC_FIXTURE_IDENTIFIER', '022');
        DEFINE('IPTC_KEYWORDS', '025');
        DEFINE('IPTC_RELEASE_DATE', '030');
        DEFINE('IPTC_RELEASE_TIME', '035');
        DEFINE('IPTC_SPECIAL_INSTRUCTIONS', '040');
        DEFINE('IPTC_REFERENCE_SERVICE', '045');
        DEFINE('IPTC_REFERENCE_DATE', '047');
        DEFINE('IPTC_REFERENCE_NUMBER', '050');
        DEFINE('IPTC_CREATED_DATE', '055');
        DEFINE('IPTC_CREATED_TIME', '060');
        DEFINE('IPTC_ORIGINATING_PROGRAM', '065');
        DEFINE('IPTC_PROGRAM_VERSION', '070');
        DEFINE('IPTC_OBJECT_CYCLE', '075');
        DEFINE('IPTC_BYLINE', '080');
        DEFINE('IPTC_BYLINE_TITLE', '085');
        DEFINE('IPTC_CITY', '090');
        DEFINE('IPTC_PROVINCE_STATE', '095');
        DEFINE('IPTC_COUNTRY_CODE', '100');
        DEFINE('IPTC_COUNTRY', '101');
        DEFINE('IPTC_ORIGINAL_TRANSMISSION_REFERENCE',     '103');
        DEFINE('IPTC_HEADLINE', '105');
        DEFINE('IPTC_CREDIT', '110');
        DEFINE('IPTC_SOURCE', '115');
        DEFINE('IPTC_COPYRIGHT_STRING', '116');
        DEFINE('IPTC_CAPTION', '120');
        DEFINE('IPTC_LOCAL_CAPTION', '121');
    
        class iptc {
            var $meta=Array();
            var $hasmeta=false;
            var $file=false;
    
    
            function iptc($filename) {
                $size = getimagesize($filename,$info);
                $this->hasmeta = isset($info["APP13"]);
                if($this->hasmeta)
                    $this->meta = iptcparse ($info["APP13"]);
                $this->file = $filename;
            }
            function set($tag, $data) {
                $this->meta ["2#$tag"]= Array( $data );
                $this->hasmeta=true;
            }
            function get($tag) {
                return isset($this->meta["2#$tag"]) ? $this->meta["2#$tag"][0] : false;
            }
    
            function dump() {
                print_r($this->meta);
            }
            function binary() {
                $iptc_new = '';
                foreach (array_keys($this->meta) as $s) {
                    $tag = str_replace("2#", "", $s);
                    $iptc_new .= $this->iptc_maketag(2, $tag, $this->meta[$s][0]);
                }        
                return $iptc_new;    
            }
            function iptc_maketag($rec,$dat,$val) {
                $len = strlen($val);
                if ($len < 0x8000) {
                       return chr(0x1c).chr($rec).chr($dat).
                       chr($len >> 8).
                       chr($len & 0xff).
                       $val;
                } else {
                       return chr(0x1c).chr($rec).chr($dat).
                       chr(0x80).chr(0x04).
                       chr(($len >> 24) & 0xff).
                       chr(($len >> 16) & 0xff).
                       chr(($len >> 8 ) & 0xff).
                       chr(($len ) & 0xff).
                       $val;
    
                }
            }    
            function write() {
                if(!function_exists('iptcembed')) return false;
                $mode = 0;
                $content = iptcembed($this->binary(), $this->file, $mode);    
                $filename = $this->file;
    
                @unlink($filename); #delete if exists
    
                $fp = fopen($filename, "w");
                fwrite($fp, $content);
                fclose($fp);
            }    
    
            #requires GD library installed
            function removeAllTags() {
                $this->hasmeta=false;
                $this->meta=Array();
                $img = imagecreatefromstring(implode(file($this->file)));
                @unlink($this->file); #delete if exists
                imagejpeg($img,$this->file,100);
            }
        };
    
    
    ?>
    

    Example read copyright string:

    $i = new iptc("test.jpg");
    echo $i->get(IPTC_COPYRIGHT_STRING); 
    

    Update copyright statement:

    $i = new iptc("test.jpg");
    echo $i->set(IPTC_COPYRIGHT_STRING,"Here goes the new data"); 
    $i->write();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a photo gallery script that involves displaying an image in a
I am making a website gallery page, and in the meta tags I have
Basicly I'm making an image gallery that downloads from the web. So - when
I'm making a C# image gallery for a website (I know there's many free
I'm making an image gallery and I want to have a bunch of thumbnails
I am making an image gallery, and I need to display images in a
I'm making a gallery with jquery. when i press a button on my page
I'm making a gallery, somewhat similar to Facebook's. I want users to be able
I'm making a sliding image gallery where there are 3 pages with 3 images
i m making a Polaroid image gallery and for which i have used dynamic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.