732f76658f31cda78bcc91677bb5b453f7aaf7ea
2 if (defined('MEDIAWIKI')) {
7 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
8 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
9 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
11 * @link http://exif.org/Exif2-2.PDF The Exif 2.2 specification
17 * @subpackage Metadata
25 * Exif tags grouped by category, the tagname itself is the key and the type
26 * is the value, in the case of more than one possible value type they are
27 * seperated by commas.
34 * A one dimentional array of all Exif tags
39 * A one dimentional array of all Exif tags that we'd want to save in
40 * the database or present on a page.
51 * Exif tag type definition
53 define('BYTE', 1); # An 8-bit unsigned integer.
54 define('ASCII', 2); # An 8-bit byte containing one 7-bit ASCII code. The final byte is terminated with NULL.
55 define('SHORT', 3); # A 16-bit (2-byte) unsigned integer.
56 define('LONG', 4); # A 32-bit (4-byte) unsigned integer.
57 define('RATIONAL', 5); # Two LONGs. The first LONG is the numerator and the second LONG expresses the denominator
58 define('UNDEFINED', 7); # An 8-bit byte that can take any value depending on the field definition
59 define('SLONG', 9); # A 32-bit (4-byte) signed integer (2's complement notation),
60 define('SRATIONAL', 10); # Two SLONGs. The first SLONG is the numerator and the second SLONG is the denominator.
64 * Page numbers here refer to pages in the EXIF 2.2 standard
66 * @link http://exif.org/Exif2-2.PDF The Exif 2.2 specification
69 # TIFF Rev. 6.0 Attribute Information (p22)
71 # Tags relating to image structure
73 'ImageWidth' => SHORT
.','.LONG
, # Image width
74 'ImageLength' => SHORT
.','.LONG
, # Image height
75 'BitsPerSample' => SHORT
, # Number of bits per component
76 # "When a primary image is JPEG compressed, this designation is not"
77 # "necessary and is omitted." (p23)
78 'Compression' => SHORT
, # Compression scheme
79 'PhotometricInterpretation' => SHORT
, # Pixel composition #p23
80 'Orientation' => SHORT
, # Orientation of image #p24
81 'SamplesPerPixel' => SHORT
, # Number of components
82 'PlanarConfiguration' => SHORT
, # Image data arrangement #p24
83 'YCbCrSubSampling' => SHORT
, # Subsampling ratio of Y to C #p24
84 'YCbCrPositioning' => SHORT
, # Y and C positioning #p24-25
85 'XResolution' => RATIONAL
, # Image resolution in width direction
86 'YResolution' => RATIONAL
, # Image resolution in height direction
87 'ResolutionUnit' => SHORT
, # Unit of X and Y resolution #(p26)
90 # Tags relating to recording offset
92 'StripOffsets' => SHORT
.','.LONG
, # Image data location
93 'RowsPerStrip' => SHORT
.','.LONG
, # Number of rows per strip
94 'StripByteCounts' => SHORT
.','.LONG
, # Bytes per compressed strip
95 'JPEGInterchangeFormat' => SHORT
.','.LONG
, # Offset to JPEG SOI
96 'JPEGInterchangeFormatLength' => SHORT
.','.LONG
, # Bytes of JPEG data
99 # Tags relating to image data characteristics
100 'characteristics' => array(
101 'TransferFunction' => SHORT
, # Transfer function
102 'WhitePoint' => RATIONAL
, # White point chromaticity
103 'PrimaryChromaticities' => RATIONAL
, # Chromaticities of primarities
104 'YCbCrCoefficients' => RATIONAL
, # Color space transformation matrix coefficients #p27
105 'ReferenceBlackWhite' => RATIONAL
# Pair of black and white reference values
110 'DateTime' => ASCII
, # File change date and time
111 'ImageDescription' => ASCII
, # Image title
112 'Make' => ASCII
, # Image input equipment manufacturer
113 'Model' => ASCII
, # Image input equipment model
114 'Software' => ASCII
, # Software used
115 'Artist' => ASCII
, # Person who created the image
116 'Copyright' => ASCII
, # Copyright holder
120 # Exif IFD Attribute Information (p30-31)
122 # Tags relating to version
124 # TODO: NOTE: Nonexistence of this field is taken to mean nonconformance
125 # to the EXIF 2.1 AND 2.2 standards
126 'ExifVersion' => UNDEFINED
, # Exif version
127 'FlashpixVersion' => UNDEFINED
, # Supported Flashpix version #p32
130 # Tags relating to Image Data Characteristics
131 'characteristics' => array(
132 'ColorSpace' => SHORT
, # Color space information #p32
135 # Tags relating to image configuration
136 'configuration' => array(
137 'ComponentsConfiguration' => UNDEFINED
, # Meaning of each component #p33
138 'CompressedBitsPerPixel' => RATIONAL
, # Image compression mode
139 'PixelYDimension' => SHORT
.','.LONG
, # Valid image width
140 'PixelXDimension' => SHORT
.','.LONG
, # Valind image height
143 # Tags relating to related user information
145 'MakerNote' => UNDEFINED
, # Manufacturer notes
146 'UserComment' => UNDEFINED
, # User comments #p34
149 # Tags relating to related file information
151 'RelatedSoundFile' => ASCII
, # Related audio file
154 # Tags relating to date and time
155 'dateandtime' => array(
156 'DateTimeOriginal' => ASCII
, # Date and time of original data generation #p36
157 'DateTimeDigitized' => ASCII
, # Date and time of original data generation
158 'SubSecTime' => ASCII
, # DateTime subseconds
159 'SubSecTimeOriginal' => ASCII
, # DateTimeOriginal subseconds
160 'SubSecTimeDigitized' => ASCII
, # DateTimeDigitized subseconds
163 # Tags relating to picture-taking conditions (p31)
164 'conditions' => array(
165 'ExposureTime' => RATIONAL
, # Exposure time
166 'FNumber' => RATIONAL
, # F Number
167 'ExposureProgram' => SHORT
, # Exposure Program #p38
168 'SpectralSensitivity' => ASCII
, # Spectral sensitivity
169 'ISOSpeedRatings' => SHORT
, # ISO speed rating
170 'OECF' => UNDEFINED
, # Optoelectronic conversion factor
171 'ShutterSpeedValue' => SRATIONAL
, # Shutter speed
172 'ApertureValue' => RATIONAL
, # Aperture
173 'BrightnessValue' => SRATIONAL
, # Brightness
174 'ExposureBiasValue' => SRATIONAL
, # Exposure bias
175 'MaxApertureValue' => RATIONAL
, # Maximum land aperture
176 'SubjectDistance' => RATIONAL
, # Subject distance
177 'MeteringMode' => SHORT
, # Metering mode #p40
178 'LightSource' => SHORT
, # Light source #p40-41
179 'Flash' => SHORT
, # Flash #p41-42
180 'FocalLength' => RATIONAL
, # Lens focal length
181 'SubjectArea' => SHORT
, # Subject area
182 'FlashEnergy' => RATIONAL
, # Flash energy
183 'SpatialFrequencyResponse' => UNDEFINED
, # Spatial frequency response
184 'FocalPlaneXResolution' => RATIONAL
, # Focal plane X resolution
185 'FocalPlaneYResolution' => RATIONAL
, # Focal plane Y resolution
186 'FocalPlaneResolutionUnit' => SHORT
, # Focal plane resolution unit
187 'SubjectLocation' => SHORT
, # Subject location
188 'ExposureIndex' => RATIONAL
, # Exposure index
189 'SensingMethod' => SHORT
, # Sensing method #p46
190 'FileSource' => UNDEFINED
, # File source #p47
191 'SceneType' => UNDEFINED
, # Scene type #p47
192 'CFAPattern' => UNDEFINED
, # CFA pattern
193 'CustomRendered' => SHORT
, # Custom image processing #p48
194 'ExposureMode' => SHORT
, # Exposure mode #p48
195 'WhiteBalance' => SHORT
, # White Balance #p49
196 'DigitalZoomRatio' => RATIONAL
, # Digital zoom ration
197 'FocalLengthIn35mmFilm' => SHORT
, # Focal length in 35 mm film
198 'SceneCaptureType' => SHORT
, # Scene capture type #p49
199 'GainControl' => RATIONAL
, # Scene control #p49-50
200 'Contrast' => SHORT
, # Contrast #p50
201 'Saturation' => SHORT
, # Saturation #p50
202 'Sharpness' => SHORT
, # Sharpness #p50
203 'DeviceSettingDescription' => UNDEFINED
, # Desice settings description
204 'SubjectDistanceRange' => SHORT
, # Subject distance range #p51
208 'ImageUniqueID' => ASCII
, # Unique image ID
212 # GPS Attribute Information (p52)
214 'GPSVersionID' => BYTE
, # GPS tag version
215 'GPSLatitudeRef' => ASCII
, # North or South Latitude #p52-53
216 'GPSLatitude' => RATIONAL
, # Latitude
217 'GPSLongitudeRef' => ASCII
, # East or West Longitude #p53
218 'GPSLongitude' => RATIONAL
, # Longitude
219 'GPSAltitudeRef' => BYTE
, # Altitude reference
220 'GPSAltitude' => RATIONAL
, # Altitude
221 'GPSTimeStamp' => RATIONAL
, # GPS time (atomic clock)
222 'GPSSatellites' => ASCII
, # Satellites used for measurement
223 'GPSStatus' => ASCII
, # Receiver status #p54
224 'GPSMeasureMode' => ASCII
, # Measurement mode #p54-55
225 'GPSDOP' => RATIONAL
, # Measurement precision
226 'GPSSpeedRef' => ASCII
, # Speed unit #p55
227 'GPSSpeed' => RATIONAL
, # Speed of GPS receiver
228 'GPSTrackRef' => ASCII
, # Reference for direction of movement #p55
229 'GPSTrack' => RATIONAL
, # Direction of movement
230 'GPSImgDirectionRef' => ASCII
, # Reference for direction of image #p56
231 'GPSImgDirection' => RATIONAL
, # Direction of image
232 'GPSMapDatum' => ASCII
, # Geodetic survey data used
233 'GPSDestLatitudeRef' => ASCII
, # Reference for latitude of destination #p56
234 'GPSDestLatitude' => RATIONAL
, # Latitude destination
235 'GPSDestLongitudeRef' => ASCII
, # Reference for longitude of destination #p57
236 'GPSDestLongitude' => RATIONAL
, # Longitude of destination
237 'GPSDestBearingRef' => ASCII
, # Reference for bearing of destination #p57
238 'GPSDestBearing' => RATIONAL
, # Bearing of destination
239 'GPSDestDistanceRef' => ASCII
, # Reference for distance to destination #p57-58
240 'GPSDestDistance' => RATIONAL
, # Distance to destination
241 'GPSProcessingMethod' => UNDEFINED
, # Name of GPS processing method
242 'GPSAreaInformation' => UNDEFINED
, # Name of GPS area
243 'GPSDateStamp' => ASCII
, # GPS date
244 'GPSDifferential' => SHORT
, # GPS differential correction
248 $this->makeFlatExifTags();
249 $this->makeValidExifTags();
253 * Get the raw list of exiftags
263 * Generate a flat list of the exif tags
265 function makeFlatExifTags() {
266 $exif = $this->getExif();
267 array_walk($exif, array(&$this, 'callback')); // note the reference
271 * A callback function used by makeFlatExifTags()
273 function callback($val, $key) {
274 if (gettype($val) === 'array')
275 array_walk($val, array(&$this, 'callback'));
277 $this->mFlatExif
[$key] = $val;
281 * Produce a list of all Exif tags appropriate for user output
283 * Produce a list of all tags that we want to show in output, in order not to
284 * output binary gibberish such as raw thumbnails we strip all tags
285 * with the datatype of UNDEFINED.
287 * @todo We might actually want to display some of the UNDEFINED
288 * stuff, but we strip it for now.
290 function makeValidExifTags() {
291 foreach($this->mFlatExif
as $key => $val) {
292 if (strpos( $val, (string)UNDEFINED
) !== false)
294 $this->mValidExif
[] = $key;
299 * The version of the output format
301 * Before the actual metadata information is saved in the database we
302 * strip some of it since we don't want to save things like thumbnails
303 * which usually accompany Exif data. This value gets saved in the
304 * database along with the actual Exif data, and if the version in the
305 * database doesn't equal the value returned by this function the Exif
306 * data is regenerated.
311 return 1; // We don't need no bloddy constants!