24 $info = &$this->getid3->info;
26 $info[
'fileformat'] =
'jpg';
27 $info[
'video'][
'dataformat'] =
'jpg';
28 $info[
'video'][
'lossless'] =
false;
29 $info[
'video'][
'bits_per_sample'] = 24;
30 $info[
'video'][
'pixel_aspect_ratio'] = (float) 1;
36 list($width, $height,
$type) = getimagesize(
$info[
'filenamepath'], $imageinfo);
39 if (isset($imageinfo[
'APP13'])) {
42 $iptc_parsed = iptcparse($imageinfo[
'APP13']);
43 if (is_array($iptc_parsed)) {
44 foreach ($iptc_parsed as $iptc_key_raw => $iptc_values) {
45 list($iptc_record, $iptc_tagkey) = explode(
'#', $iptc_key_raw);
46 $iptc_tagkey = intval(ltrim($iptc_tagkey,
'0'));
47 foreach ($iptc_values as
$key => $value) {
50 if (isset(
$info[
'iptc'][
'comments'][$IPTCrecordName][$IPTCrecordTagName])) {
51 $info[
'iptc'][
'comments'][$IPTCrecordName][$IPTCrecordTagName][] = $value;
53 $info[
'iptc'][
'comments'][$IPTCrecordName][$IPTCrecordTagName] = array($value);
63 $info[
'video'][
'resolution_x'] = $width;
64 $info[
'video'][
'resolution_y'] = $height;
66 if (isset($imageinfo[
'APP1'])) {
67 if (function_exists(
'exif_read_data')) {
68 if (substr($imageinfo[
'APP1'], 0, 4) ==
'Exif') {
71 set_error_handler(
function($errno, $errstr, $errfile, $errline, array $errcontext) {
72 if (!(error_reporting() & $errno)) {
77 $errcontext[
'info'][
'warning'][] =
'Error parsing EXIF data ('.$errstr.
')';
80 $info[
'jpg'][
'exif'] = exif_read_data($info[
'filenamepath'], null,
true,
false);
82 restore_error_handler();
84 $this->
warning(
'exif_read_data() cannot parse non-EXIF data in APP1 (expected "Exif", found "'.substr($imageinfo[
'APP1'], 0, 4).
'")');
87 $this->
warning(
'EXIF parsing only available when '.(GETID3_OS_ISWINDOWS ?
'php_exif.dll enabled' :
'compiled with --enable-exif'));
98 $cast_as_appropriate_keys = array(
'EXIF',
'IFD0',
'THUMBNAIL');
99 foreach ($cast_as_appropriate_keys as $exif_key) {
100 if (isset(
$info[
'jpg'][
'exif'][$exif_key])) {
101 foreach (
$info[
'jpg'][
'exif'][$exif_key] as
$key => $value) {
108 if (isset(
$info[
'jpg'][
'exif'][
'GPS'])) {
110 if (isset(
$info[
'jpg'][
'exif'][
'GPS'][
'GPSVersion'])) {
111 for (
$i = 0;
$i < 4;
$i++) {
112 $version_subparts[
$i] = ord(substr(
$info[
'jpg'][
'exif'][
'GPS'][
'GPSVersion'],
$i, 1));
114 $info[
'jpg'][
'exif'][
'GPS'][
'computed'][
'version'] =
'v'.implode(
'.', $version_subparts);
117 if (isset(
$info[
'jpg'][
'exif'][
'GPS'][
'GPSDateStamp'])) {
118 $explodedGPSDateStamp = explode(
':',
$info[
'jpg'][
'exif'][
'GPS'][
'GPSDateStamp']);
119 $computed_time[5] = (isset($explodedGPSDateStamp[0]) ? $explodedGPSDateStamp[0] :
'');
120 $computed_time[3] = (isset($explodedGPSDateStamp[1]) ? $explodedGPSDateStamp[1] :
'');
121 $computed_time[4] = (isset($explodedGPSDateStamp[2]) ? $explodedGPSDateStamp[2] :
'');
123 $computed_time = array(0=>0, 1=>0, 2=>0, 3=>0, 4=>0, 5=>0);
124 if (isset(
$info[
'jpg'][
'exif'][
'GPS'][
'GPSTimeStamp']) && is_array(
$info[
'jpg'][
'exif'][
'GPS'][
'GPSTimeStamp'])) {
125 foreach (
$info[
'jpg'][
'exif'][
'GPS'][
'GPSTimeStamp'] as
$key => $value) {
129 $info[
'jpg'][
'exif'][
'GPS'][
'computed'][
'timestamp'] = gmmktime($computed_time[0], $computed_time[1], $computed_time[2], $computed_time[3], $computed_time[4], $computed_time[5]);
132 if (isset(
$info[
'jpg'][
'exif'][
'GPS'][
'GPSLatitude']) && is_array(
$info[
'jpg'][
'exif'][
'GPS'][
'GPSLatitude'])) {
133 $direction_multiplier = ((isset(
$info[
'jpg'][
'exif'][
'GPS'][
'GPSLatitudeRef']) && (
$info[
'jpg'][
'exif'][
'GPS'][
'GPSLatitudeRef'] ==
'S')) ? -1 : 1);
134 foreach (
$info[
'jpg'][
'exif'][
'GPS'][
'GPSLatitude'] as
$key => $value) {
137 $info[
'jpg'][
'exif'][
'GPS'][
'computed'][
'latitude'] = $direction_multiplier * ($computed_latitude[0] + ($computed_latitude[1] / 60) + ($computed_latitude[2] / 3600));
140 if (isset(
$info[
'jpg'][
'exif'][
'GPS'][
'GPSLongitude']) && is_array(
$info[
'jpg'][
'exif'][
'GPS'][
'GPSLongitude'])) {
141 $direction_multiplier = ((isset(
$info[
'jpg'][
'exif'][
'GPS'][
'GPSLongitudeRef']) && (
$info[
'jpg'][
'exif'][
'GPS'][
'GPSLongitudeRef'] ==
'W')) ? -1 : 1);
142 foreach (
$info[
'jpg'][
'exif'][
'GPS'][
'GPSLongitude'] as
$key => $value) {
145 $info[
'jpg'][
'exif'][
'GPS'][
'computed'][
'longitude'] = $direction_multiplier * ($computed_longitude[0] + ($computed_longitude[1] / 60) + ($computed_longitude[2] / 3600));
147 if (isset(
$info[
'jpg'][
'exif'][
'GPS'][
'GPSAltitudeRef'])) {
148 $info[
'jpg'][
'exif'][
'GPS'][
'GPSAltitudeRef'] = ord(
$info[
'jpg'][
'exif'][
'GPS'][
'GPSAltitudeRef']);
150 if (isset(
$info[
'jpg'][
'exif'][
'GPS'][
'GPSAltitude'])) {
151 $direction_multiplier = (!empty(
$info[
'jpg'][
'exif'][
'GPS'][
'GPSAltitudeRef']) ? -1 : 1);
159 if (isset(
$info[
'filenamepath'])) {
161 $xmp_raw = $image_xmp->getAllTags();
162 foreach ($xmp_raw as
$key => $value) {
163 if (strpos(
$key,
':')) {
164 list($subsection, $tagname) = explode(
':',
$key);
167 $this->
warning(
'XMP: expecting "<subsection>:<tagname>", found "'.
$key.
'"');
173 unset(
$info[
'fileformat']);
181 if (is_array($value)) {
183 } elseif (preg_match(
'#^[0-9]+/[0-9]+$#', $value)) {
185 } elseif (preg_match(
'#^[0-9]+$#', $value)) {
187 } elseif (preg_match(
'#^[0-9\.]+$#', $value)) {
188 return (
float) $value;
196 static $IPTCrecordName = array();
197 if (empty($IPTCrecordName)) {
198 $IPTCrecordName = array(
200 2 =>
'IPTCApplication',
201 3 =>
'IPTCNewsPhoto',
202 7 =>
'IPTCPreObjectData',
203 8 =>
'IPTCObjectData',
204 9 =>
'IPTCPostObjectData',
207 return (isset($IPTCrecordName[$iptc_record]) ? $IPTCrecordName[$iptc_record] :
'');
213 static $IPTCrecordTagName = array();
214 if (empty($IPTCrecordTagName)) {
215 $IPTCrecordTagName = array(
217 0 =>
'EnvelopeRecordVersion',
221 30 =>
'ServiceIdentifier',
222 40 =>
'EnvelopeNumber',
224 60 =>
'EnvelopePriority',
227 90 =>
'CodedCharacterSet',
228 100 =>
'UniqueObjectName',
229 120 =>
'ARMIdentifier',
233 0 =>
'ApplicationRecordVersion',
234 3 =>
'ObjectTypeReference',
235 4 =>
'ObjectAttributeReference',
238 8 =>
'EditorialUpdate',
240 12 =>
'SubjectReference',
242 20 =>
'SupplementalCategories',
243 22 =>
'FixtureIdentifier',
245 26 =>
'ContentLocationCode',
246 27 =>
'ContentLocationName',
249 37 =>
'ExpirationDate',
250 38 =>
'ExpirationTime',
251 40 =>
'SpecialInstructions',
252 42 =>
'ActionAdvised',
253 45 =>
'ReferenceService',
254 47 =>
'ReferenceDate',
255 50 =>
'ReferenceNumber',
258 62 =>
'DigitalCreationDate',
259 63 =>
'DigitalCreationTime',
260 65 =>
'OriginatingProgram',
261 70 =>
'ProgramVersion',
264 85 =>
'By-lineTitle',
266 92 =>
'Sub-location',
267 95 =>
'Province-State',
268 100 =>
'Country-PrimaryLocationCode',
269 101 =>
'Country-PrimaryLocationName',
270 103 =>
'OriginalTransmissionReference',
274 116 =>
'CopyrightNotice',
276 120 =>
'Caption-Abstract',
277 121 =>
'LocalCaption',
278 122 =>
'Writer-Editor',
279 125 =>
'RasterizedCaption',
281 131 =>
'ImageOrientation',
282 135 =>
'LanguageIdentifier',
284 151 =>
'AudioSamplingRate',
285 152 =>
'AudioSamplingResolution',
286 153 =>
'AudioDuration',
287 154 =>
'AudioOutcue',
289 185 =>
'MasterDocumentID',
290 186 =>
'ShortDocumentID',
291 187 =>
'UniqueDocumentID',
293 200 =>
'ObjectPreviewFileFormat',
294 201 =>
'ObjectPreviewFileVersion',
295 202 =>
'ObjectPreviewData',
297 225 =>
'ClassifyState',
298 228 =>
'SimilarityIndex',
299 230 =>
'DocumentNotes',
300 231 =>
'DocumentHistory',
301 232 =>
'ExifCameraInfo',
304 0 =>
'NewsPhotoVersion',
305 10 =>
'IPTCPictureNumber',
306 20 =>
'IPTCImageWidth',
307 30 =>
'IPTCImageHeight',
308 40 =>
'IPTCPixelWidth',
309 50 =>
'IPTCPixelHeight',
310 55 =>
'SupplementalType',
311 60 =>
'ColorRepresentation',
312 64 =>
'InterchangeColorSpace',
313 65 =>
'ColorSequence',
315 70 =>
'ColorCalibrationMatrix',
317 84 =>
'NumIndexEntries',
318 85 =>
'ColorPalette',
319 86 =>
'IPTCBitsPerSample',
320 90 =>
'SampleStructure',
321 100 =>
'ScanningDirection',
322 102 =>
'IPTCImageRotation',
323 110 =>
'DataCompressionMethod',
324 120 =>
'QuantizationMethod',
326 130 =>
'ExcursionTolerance',
327 135 =>
'BitsPerComponent',
328 140 =>
'MaximumDensityRange',
329 145 =>
'GammaCompensatedValue',
333 20 =>
'MaxSubfileSize',
334 90 =>
'ObjectSizeAnnounced',
335 95 =>
'MaximumObjectSize',
341 10 =>
'ConfirmedObjectSize',
346 return (isset($IPTCrecordTagName[$iptc_record][$iptc_tagkey]) ? $IPTCrecordTagName[$iptc_record][$iptc_tagkey] : $iptc_tagkey);
IPTCrecordName($iptc_record)
static DecimalizeFraction($fraction)
IPTCrecordTagName($iptc_record, $iptc_tagkey)
static IncludeDependency($filename, $sourcefile, $DieOnFailure=false)
getID3() by James Heinrich info@getid3.org //
static CastAsInt($floatnum)
fseek($bytes, $whence=SEEK_SET)
CastAsAppropriate($value)
getID3() by James Heinrich info@getid3.org //