ZenphotoCMS 1.6.2

exif.php

Exifer 1.7 Extracts EXIF information from digital photos.

Originally created by: Copyright © 2005 Jake Olefsky http:// www.offsky.com/software/exif/index.php jake@olefsky.com

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. http:// www.gnu.org/copyleft/gpl.html

SUMMARY: This script will correctly parse all of the EXIF data included in images taken with digital cameras. It will read the IDF0, IDF1, SubIDF and InteroperabilityIFD fields as well as parsing some of the MakerNote fields that vary depending on camera make and model. This script parses more tags than the internal PHP exif implementation and it will correctly identify and decode what all the values mean. This version will correctly parse the MakerNote field for Nikon, Olympus, and Canon digital cameras. Others will follow.

TESTED WITH:

  • Nikon CoolPix 700
  • Nikon CoolPix E3200
  • Nikon CoolPix 4500
  • Nikon CoolPix 950
  • Nikon Coolpix 5700
  • Canon PowerShot S200
  • Canon PowerShot S110
  • Olympus C2040Z
  • Olympus C960
  • Olumpus E-300
  • Olympus E-410
  • Olympus E-500
  • Olympus E-510
  • Olympus E-3
  • Canon Ixus
  • Canon EOS 300D
  • Canon Digital Rebel
  • Canon EOS 10D
  • Canon PowerShot G2
  • FujiFilm DX 10
  • FujiFilm MX-1200
  • FujiFilm FinePix2400
  • FujiFilm FinePix2600
  • FujiFilm FinePix S602
  • FujiFilm FinePix40i
  • Sony D700
  • Sony Cybershot
  • Kodak DC210
  • Kodak DC240
  • Kodak DC4800
  • Kodak DX3215
  • Ricoh RDC-5300
  • Sanyo VPC-G250
  • Sanyo VPC-SX550
  • Epson 3100z

VERSION HISTORY:

1.0 September 23, 2002

  • First Public Release

1.1 January 25, 2003

  • Gracefully handled the error case where you pass an empty string to this library
  • Fixed an inconsistency in the Olympus Camera parsing module
  • Added support for parsing the MakerNote of Canon images.
  • Modified how the imagefile is opened so it works for windows machines.
  • Correctly parses the FocalPlaneResolutionUnit and PhotometricInterpretation fields
  • Negative rational numbers are properly displayed
  • Strange old cameras that use Motorola endineness are now properly supported
  • Tested with several more cameras

Potential Problem: Negative Shorts and Negative Longs may not be correctly displayed, but I have not yet found an example of negative shorts or longs being used.

1.2 March 30, 2003

  • Fixed an error that was displayed if you edited your image with WinXP's image viewer
  • Fixed a bug that caused some images saved from 3rd party software to not parse correctly
  • Changed the ExposureTime tag to display in fractional seconds rather than decimal
  • Updated the ShutterSpeedValue tag to have the units of 'sec'
  • Added support for parsing the MakeNote of FujiFilm images
  • Added support for parsing the MakeNote of Sanyo images
  • Fixed a bug with parsing some Olympus MakerNote tags
  • Tested with several more cameras

1.3 June 15, 2003

  • Fixed Canon MakerNote support for some models (Canon has very difficult and inconsistent MakerNote syntax)
  • Negative signed shorts and negative signed longs are properly displayed
  • Several more tags are defined
  • More information in my comments about what each tag is
  • Parses and Displays GPS information if available
  • Tested with several more cameras

1.4 September 14, 2003

  • This software is now licensed under the GNU General Public License

  • Exposure time is now correctly displayed when the numerator is 10

  • Fixed the calculation and display of ShutterSpeedValue, ApertureValue and MaxApertureValue

  • Fixed a bug with the GPS code

  • Tested with several more cameras

    1.5 February 18, 2005

  • It now gracefully deals with a passed in file that cannot be found.

  • Fixed a GPS bug for the parsing of Altitude and other signed rational numbers

  • Defined more values for Canon cameras.

  • Added 'bulb' detection for ShutterSpeed

  • Made script loading a little faster and less memory intensive.

  • Bug fixes

  • Better error reporting

  • Graceful failure for files with corrupt exif info.

  • QuickTime (including iPhoto) messes up the Makernote tag for certain photos (no workaround yet)

  • Now reads exif information when the jpeg markers are out of order

  • Gives raw data output for IPTC, COM and APP2 fields which are sometimes set by other applications

  • Improvements to Nikon Makernote parsing

1.6 March 25th, 2007 [Zenphoto]

  • Adopted into the Zenphoto gallery project, at https://www.zenphoto.org
  • Fixed a bug where strings had trailing null bytes.
  • Formatted selected strings better.
  • Added calculation of 35mm-equivalent focal length when possible.
  • Cleaned up code for readability and efficiency.

1.7 April 11th, 2008 [Zenphoto]

  • Fixed bug with newer Olympus cameras where number of fields was miscalculated leading to bad performance.
  • More logical fraction calculation for shutter speed.

2009: For all further changes, see the Zenphoto change logs.

Table of Contents

Functions

intel2Moto()  : array<string|int, mixed>
Converts from Intel to Motorola endien. Just reverses the bytes (assumes hex is passed in)
lookup_tag()  : string
Looks up the name of the tag
lookup_type()  : string
Looks up the datatype
validSize()  : type
truncates unreasonable read data requests.
unRational()  : string
processes a irrational number
rational()  : type
processes a rational number
formatData()  : type
Formats Data for the data type
formatExposure()  : type
read_entry()  : type
Reads one standard IFD entry
read_exif_data_raw()  : int
Pass in a file and this reads the EXIF data
ConvertToFraction()  : type
Converts a floating point number into a simple fraction.
get35mmEquivFocalLength()  : int
Calculates the 35mm-equivalent focal length from the reported sensor resolution

Functions

intel2Moto()

Converts from Intel to Motorola endien. Just reverses the bytes (assumes hex is passed in)

intel2Moto(type $intel) : array<string|int, mixed>
Parameters
$intel : type
Tags
staticvar

array $cache

Return values
array<string|int, mixed>

lookup_tag()

Looks up the name of the tag

lookup_tag(string $tag) : string
Parameters
$tag : string
Return values
string

lookup_type()

Looks up the datatype

lookup_type(type &$type, type &$size) : string
Parameters
$type : type
$size : type
Return values
string

validSize()

truncates unreasonable read data requests.

validSize(type $bytesofdata) : type
Parameters
$bytesofdata : type
Return values
type

unRational()

processes a irrational number

unRational(type $data, type $type, type $intel) : string
Parameters
$data : type
$type : type
$intel : type
Return values
string

rational()

processes a rational number

rational(type $data, type $type, type $intel) : type
Parameters
$data : type
$type : type
$intel : type
Return values
type

formatData()

Formats Data for the data type

formatData(type $type, type $tag, type $intel, type $data) : type
Parameters
$type : type
$tag : type
$intel : type
$data : type
Return values
type

formatExposure()

formatExposure(type $data) : type
Parameters
$data : type
Return values
type

read_entry()

Reads one standard IFD entry

read_entry(type &$result, type $in, type $seek, type $intel, type $ifd_name, type $globalOffset) : type
Parameters
$result : type
$in : type
$seek : type
$intel : type
$ifd_name : type
$globalOffset : type
Return values
type

read_exif_data_raw()

Pass in a file and this reads the EXIF data

read_exif_data_raw(string $path, int $verbose) : int

Usefull resources

  • http:// www.ba.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
  • http:// www.w3.org/Graphics/JPEG/jfif.txt
  • http:// exif.org/
  • http:// www.ozhiker.com/electronics/pjmt/library/list_contents.php4
  • http:// www.ozhiker.com/electronics/pjmt/jpeg_info/makernotes.html
  • http:// pel.sourceforge.net/
  • http:// us2.php.net/manual/en/function.exif-read-data.php
Parameters
$path : string
$verbose : int
Return values
int

ConvertToFraction()

Converts a floating point number into a simple fraction.

ConvertToFraction(type $v, type &$n, type &$d) : type
Parameters
$v : type
$n : type
$d : type
Return values
type

get35mmEquivFocalLength()

Calculates the 35mm-equivalent focal length from the reported sensor resolution

get35mmEquivFocalLength(array<string|int, mixed> &$result) : int
Parameters
$result : array<string|int, mixed>
Tags
author

Tristan Harward (trisweb)

Return values
int

        
On this page

Search results