|

楼主 |
发表于 2011-8-26 15:16
|
显示全部楼层
function get_exif_info($exif) {
$exif_match = array();
$exif_match['Make'] = "Make";
$exif_match['Model'] = "Model";
$exif_match['DateTimeOriginal'] = "DateTimeOriginal";
$exif_match['ISOSpeedRatings'] = "ISOSpeedRatings";
$exif_match['ExposureTime'] = "ExposureTime";
$exif_match['FNumber'] = "FNumber";
$exif_match['FocalLength'] = "FocalLength";
$exif_match['ExposureBiasValue'] = "ExposureBiasValue";
$exif_match['ApertureValue'] = "ApertureValue";
$exif_match['MaxApertureValue'] = "MaxApertureValue";
$exif_match['MeteringMode'] = "MeteringMode";
$exif_match['Flash'] = "Flash";
$exif_match['ExposureProgram'] = "ExposureProgram";
$exif_match['ExposureMode'] = "ExposureMode";
$exif_match['WhiteBalance'] = "WhiteBalance";
$exif_match['GPSLatitude'] = "GPSLatitude";
$exif_match['GPSLatitudeRef'] = "GPSLatitudeRef";
$exif_match['GPSLongitude'] = "GPSLongitude";
$exif_match['GPSLongitudeRef'] = "GPSLongitudeRef";
$exif_match['GPSAltitude'] = "GPSAltitude";
$exif_match['GPSTrack'] = "GPSTrack";
$exif_array = array();
if (is_array($exif)) {
foreach ($exif as $key => $val) {
if (isset($exif_match[$key])) {
$exif_info = $val;
if ($key == "DateTimeOriginal") {
$exif_array[$exif_match[$key]] = preg_replace("/([0-9]{4}):([0-9]{2}):([0-9]{2})/", "\\3.\\2.\\1", $exif_info);
}
elseif ( $key == "ExposureTime" ) {
$ExposureTime = explode("/", $exif_info);
if(($ExposureTime[0]/$ExposureTime[1]) >= 0.3 ) {
$exif_array[$exif_match[$key]] = round(($ExposureTime[0]/$ExposureTime[1]),1)." sec(s)";
}
else{
$exif_array[$exif_match[$key]] = "1/".round((1/($ExposureTime[0]/$ExposureTime[1])),0)." sec(s)";
}
}
elseif ($key == "FNumber") {
$FNumber = explode("/", $exif_info);
$exif_array[$exif_match[$key]] = "F/" . ($FNumber[0] / $FNumber[1]);
}
elseif ($key == "FocalLength") {
$FocalLength = explode("/", $exif_info);
$exif_array[$exif_match[$key]] = round(($FocalLength[0] / $FocalLength[1])) . " mm";
}
elseif ($key == "ExposureBiasValue") {
$ExposureBiasValue = explode("/", $exif_info);
$exif_array[$exif_match[$key]] = round(($ExposureBiasValue[0] / $ExposureBiasValue[1]), 1) . " EV";
}
elseif ($key == "ApertureValue") {
$ApertureValue = explode("/", $exif_info);
$exif_array[$exif_match[$key]] ="F/" . round(($ApertureValue[0] / $ApertureValue[1]), 1);
}
elseif ($key == "MaxApertureValue") {
$MaxApertureValue = explode("/", $exif_info);
$exif_array[$exif_match[$key]] ="F/" . round((pow(sqrt(2),$MaxApertureValue[0] / $MaxApertureValue[1])), 1);
}
elseif ($key == "MeteringMode") {
if($exif_info == 0) {$MeteringMode = "Unbekannt";}
if($exif_info == 1) {$MeteringMode = "Durchschnitt";}
if($exif_info == 2) {$MeteringMode = "Mittenbetont";}
if($exif_info == 3) {$MeteringMode = "Spot";}
if($exif_info == 4) {$MeteringMode = "Multi-Spot";}
if($exif_info == 5) {$MeteringMode = "Multi-Segment";}
if($exif_info == 6) {$MeteringMode = "Selektiv";}
if($exif_info == 255) {$MeteringMode = "Unbekannt";}
$exif_array[$exif_match[$key]] = ($MeteringMode);
}
elseif ($key == "Flash") {
if($exif_info == 0) {$Flash = "Kein Blitz";}
if($exif_info == 1) {$Flash = "Blitz ausgelöst";}
if($exif_info == 5) {$Flash = "Blitz ausgelöst but strobe return light not detected";}
if($exif_info == 7) {$Flash = "Blitz ausgelöst and strobe return light detected";}
if($exif_info == 9) {$Flash = "Blitz ausgelöst, erzwungener Blitz";}
if($exif_info == 13) {$Flash = "Blitz ausgelöst, erzwungener Blitz, return light not detected";}
if($exif_info == 15) {$Flash = "Blitz ausgelöst, erzwungener Blitz, return light detected";}
if($exif_info == 16) {$Flash = "Blitz nicht ausgelöst";}
if($exif_info == 24) {$Flash = "Flash did not fire, auto mode";}
if($exif_info == 25) {$Flash = "Blitz ausgelöst, auto mode";}
if($exif_info == 29) {$Flash = "Blitz ausgelöst, auto mode, return light not detected";}
if($exif_info == 31) {$Flash = "Blitz ausgelöst, auto mode, return light detected";}
if($exif_info == 32) {$Flash = "keine Blitzfunktion";}
if($exif_info == 65) {$Flash = "Blitz ausgelöst, Rote Augen Reduktion";}
if($exif_info == 69) {$Flash = "Blitz ausgelöst, Rote Augen Reduktion, return light not detected";}
if($exif_info == 71) {$Flash = "Blitz ausgelöst, Rote Augen Reduktion, return light detected";}
if($exif_info == 73) {$Flash = "Blitz ausgelöst, erzwungener Blitz, Rote Augen Reduktion";}
if($exif_info == 77) {$Flash = "Blitz ausgelöst, erzwungener Blitz, Rote Augen Reduktion, return light not detected";}
if($exif_info == 79) {$Flash = "Blitz ausgelöst, erzwungener Blitz, Rote Augen Reduktion, red-eye reduction mode, return light detected";}
if($exif_info == 89) {$Flash = "Blitz ausgelöst, auto mode, Rote Augen Reduktion";}
if($exif_info == 93) {$Flash = "Blitz ausgelöst, auto mode, return light not detected, Rote Augen Reduktion";}
if($exif_info == 95) {$Flash = "Blitz ausgelöst, auto mode, return light detected, Rote Augen Reduktion";}
$exif_array[$exif_match[$key]] = ($Flash);
}
elseif ($key == "ExposureProgram") {
if($exif_info == 1) {$ExposureProgram = "Manuell";}
if($exif_info == 2) {$ExposureProgram = "Programmautomatik";}
if($exif_info == 3) {$ExposureProgram = "Zeitautomatik";}
if($exif_info == 4) {$ExposureProgram = "Blendenautomatik";}
if($exif_info == 5) {$ExposureProgram = "Stilleben";}
if($exif_info == 6) {$ExposureProgram = "Sport";}
if($exif_info == 7) {$ExposureProgram = "Portrait";}
if($exif_info == 8) {$ExposureProgram = "Landschaft";}
$exif_array[$exif_match[$key]] = ($ExposureProgram);
}
elseif ($key == "ExposureMode") {
if($exif_info == 0) {$ExposureMode = "Automatisch";}
if($exif_info == 1) {$ExposureMode = "Manuell";}
if($exif_info == 2) {$ExposureMode = "Belichtungsreihe";}
if($exif_info == 255) {$ExposureMode = "Unbekannt";}
$exif_array[$exif_match[$key]] = ($ExposureMode);
}
elseif ($key == "WhiteBalance") {
if($exif_info == 0) {$WhiteBalance = "Automatisch";}
if($exif_info == 1) {$WhiteBalance = "Manuell";}
$exif_array[$exif_match[$key]] = ($WhiteBalance);
}
elseif ($key == "GPSLatitudeRef") {
if ($exif_info == 'N') {$GPSLatitudeRef = "Nord";$GPSLatfaktor = 1;}
if ($exif_info == 'S') {$GPSLatitudeRef = "Süd"; $GPSLatfaktor = -1;}
$exif_array[$exif_match[$key]] = ($GPSLatitudeRef);
}
elseif ($key == "GPSLongitudeRef") {
if ($exif_info == 'E') {$GPSLongitudeRef = "Ost";$GPSLongfaktor = 1;}
if ($exif_info == 'W') {$GPSLongitudeRef = "West";$GPSLongfaktor = -1;}
$exif_array[$exif_match[$key]] = ($GPSLongitudeRef);
}
elseif ($key == "GPSLatitude") {
$GPSLatitude_h = explode("/", $exif_info[0]);
$GPSLatitude_m = explode("/", $exif_info[1]);
$GPSLatitude_s = explode("/", $exif_info[2]);
$GPSLat_h = $GPSLatitude_h[0] / $GPSLatitude_h[1];
$GPSLat_m = $GPSLatitude_m[0] / $GPSLatitude_m[1];
$GPSLat_s = round($GPSLatitude_s[0] / $GPSLatitude_s[1],6);
$GPSLatGrad = $GPSLatfaktor * ($GPSLat_h + ($GPSLat_m + ($GPSLat_s / 60))/60);
$exif_array[$exif_match[$key]] = ($GPSLatGrad);
}
elseif ($key == "GPSLongitude") {
$GPSLongitude_h = explode("/", $exif_info[0]);
$GPSLongitude_m = explode("/", $exif_info[1]);
$GPSLongitude_s = explode("/", $exif_info[2]);
$GPSLong_h = $GPSLongitude_h[0] / $GPSLongitude_h[1];
$GPSLong_m = $GPSLongitude_m[0] / $GPSLongitude_m[1];
$GPSLong_s = round($GPSLongitude_s[0] / $GPSLongitude_s[1],6);
$GPSLongGrad = $GPSLongfaktor * ($GPSLong_h + ($GPSLong_m + ($GPSLong_s / 60))/60);
$exif_array[$exif_match[$key]] = ($GPSLongGrad);
}
elseif ($key == "GPSAltitudeRef") {
$GPSAltitudeRef = bin2hex($exif_info[0]);
if($GPSAltitudeRef == 00) {$GPSAltitudeRef = " über Meeresspiegel";}
if($GPSAltitudeRef == 01) {$GPSAltitudeRef = " unter Meeresspiegel";}
$exif_array[$exif_match[$key]] = ($GPSAltitudeRef);
}
elseif ($key == "GPSAltitude") {
$GPSAltitude = explode("/", $exif_info);
$exif_array [$exif_match[$key]] = round(($GPSAltitude[0] / $GPSAltitude[1])) ." m";
}
elseif ($key == "GPSTrack") {
$GPSTrack = explode("/", $exif_info);
$exif_array[$exif_match[$key]] = ($GPSTrack[0]/$GPSTrack[1]) . "°";
}
else {
$exif_array[$exif_match[$key]] = $exif_info;
}
}
}
}
return $exif_array;
}
// ##################### End EXIF #######################################
[[i] 本帖最后由 Coolaq 于 2011-8-26 15:23 编辑 [/i]] |
|