Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2005
    Posts
    97
    Thanks
    7
    Thanked 7 Times in 7 Posts

    Extracting comments from a JPG

    Can anyone point me to some good reading material on extracting windowsXP comments from a .jpg file?

    I was thinking it might be nice to be able to extract the comments from a .jpg file (right click/properties then the title. author, comments bit) but I'm having a bit of a job finding out if such a thing is even possible using php.

    I'm guessing these comments are some sort of EXIF or IPTC data but most links I find seem to talk about extracting the shutterspeed and resolution type data embedded by some digital cameras.

    Can someone throw me a link or two please?

  • #2
    Regular Coder
    Join Date
    Jun 2005
    Posts
    804
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've never tried it, but exif_read_data() might by what you're looking for.

  • #3
    New Coder
    Join Date
    Feb 2005
    Posts
    97
    Thanks
    7
    Thanked 7 Times in 7 Posts
    Thanks Kid.

    I just thought I'd report back with my findings in case anyone else was interested. Using the info on the link you gave me a fiddled around with the code a bit so that it reads and returns only the comments.

    There may well be a more efficient way of doing this, at present it loops through all the headers looking for the WINMX.Comments header so any improvements welcomed

    Code:
    <?php
    $exif = exif_read_data('test.jpg', 0, true);
    foreach ($exif as $key => $section) {
      foreach ($section as $name => $val) {
       }
    }
    if ($key.$name = "WINXP.Comments") {
    	if ($val=="") {
    		echo "There are no comments for this file.";
    		}
    		else {
    		echo "$val";
    	}
    	}
    ?>
    Please not that this line if ($val=="") needs to have the one of those little square zero things in between the speach marks, like what you would see all over the screen if you opened an image file with notepad. No idea what they are called but they look like this [] sort of, Null characters?

    As I said there are probably better ways of doing this but there you go


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •