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']);
IPTCrecordName($iptc_record)
static DecimalizeFraction($fraction)
IPTCrecordTagName($iptc_record, $iptc_tagkey)
static IncludeDependency($filename, $sourcefile, $DieOnFailure=false)
getID3() by James Heinrich info@getid3.org //
fseek($bytes, $whence=SEEK_SET)
CastAsAppropriate($value)