View Full Version : extracting attributes from jpeg file
04-17-2003, 12:36 AM
What do I mean by 'additional' attributes - when you view the properties of a .jpg in windows you can see additional attributes such as:
- Date Picture Taken
- Horizontal Resolution
- Shutter Speed
etc. I want to extract some of these properties via code so they can be displayed on a photo gallery website.
Thanks in advance.
You can't do this with graphics, you have to use server side code to query the image itself (possibly in conjunction with a DB) in order to get that information. In PHP it would be simple:
$imagepath = '/full/image/path/to.gif';
$imgxy = getimagesize($imagepath);
//$imgxy = width
//$imgxy = height
//$imgxy = image type: a flag indicating the type of the image: 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF
//$imgxy = 'width="xx" height="xx"' for use in SRC
echo 'last modified: ' . date ('F d Y H:i:s.', filemtime($imagepath));
But you aren't going to get the date the pic was taken, just the date it was uploaded/modified. (unless it is a user entered field).
Also, there's no way you can get shutter speed in a jpg as its header informaiton doesn't contain it, jpg just doesn't care (nor should it) about that.
04-17-2003, 10:37 AM
Moving to php forum....
04-17-2003, 06:16 PM
The jpeg format does seem to have some provision for header info as windows is able to display a whole list of attributes for jpegs I have taken, e.g. "Date Photo Taken", "Equipment Make".
I notice that jpeg's taken with a different camera have a different set of 'additional' attributes.
There must be a way to programmatically extract these as both XP and the Canon Zoombrowser software are able to display this info.
04-17-2003, 06:50 PM
You are correct.
JPEG files do have the ability to carry a lot of additional info. I'm not sure exactly how, or what the format is, but I will have a look and then post again. :)
::] krycek [::
04-17-2003, 06:53 PM
I thought I had seen some info a while back - here it is :D
Quite a bit to read there!
::] krycek [::
if you have PHP4.3+ with GD2+ you can read/alter any of the iptc channeled information of any jpeg image very easily.
check the iptcparse and iptcembed functions of GD within the php.net manual for more information.
subnote: read exif data will return a small portion of the above , the exif functions will not allow writing or rewriting of the image information though.
04-17-2003, 08:45 PM
Thanks a lot Feyd, krycek and Íkii.
This has helped me out greatly and hopefully I should be able to figure it out from here.
Some more informaiton for you on getting the EXIF information from a jpg...
07-07-2003, 02:49 PM
You can use Pear if you are on win32 and dont want to recompile:
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.