Example #1
0
function formatOlympusData($type, $tag, $intel, $data)
{
    if ($type == "ASCII") {
    } else {
        if ($type == "URATIONAL" || $type == "SRATIONAL") {
            $data = unRational($data, $type, $intel);
            if ($intel == 1) {
                $data = intel2Moto($data);
            }
            if ($tag == "0204") {
                //DigitalZoom
                $data = $data . "x";
            }
            if ($tag == "0205") {
                //Unknown2
            }
        } else {
            if ($type == "USHORT" || $type == "SSHORT" || $type == "ULONG" || $type == "SLONG" || $type == "FLOAT" || $type == "DOUBLE") {
                $data = rational($data, $type, $intel);
                if ($tag == "0201") {
                    //JPEGQuality
                    if ($data == 1) {
                        $data = "SQ";
                    } else {
                        if ($data == 2) {
                            $data = "HQ";
                        } else {
                            if ($data == 3) {
                                $data = "SHQ";
                            } else {
                                $data = gettext("Unknown") . ": " . $data;
                            }
                        }
                    }
                }
                if ($tag == "0202") {
                    //Macro
                    if ($data == 0) {
                        $data = "Normal";
                    } else {
                        if ($data == 1) {
                            $data = "Macro";
                        } else {
                            $data = gettext("Unknown") . ": " . $data;
                        }
                    }
                }
            } else {
                if ($type == "UNDEFINED") {
                } else {
                    $data = bin2hex($data);
                    if ($intel == 1) {
                        $data = intel2Moto($data);
                    }
                }
            }
        }
    }
    return $data;
}
Example #2
0
function formatSanyoData($type, $tag, $intel, $data)
{
    if ($type == "ASCII") {
    } else {
        if ($type == "URATIONAL" || $type == "SRATIONAL") {
            $data = unRational($data, $type, $intel);
        } else {
            if ($type == "USHORT" || $type == "SSHORT" || $type == "ULONG" || $type == "SLONG" || $type == "FLOAT" || $type == "DOUBLE") {
                $data = rational($data, $type, $intel);
                if ($tag == "0200") {
                    //SpecialMode
                    if ($data == 0) {
                        $data = gettext("Normal");
                    } else {
                        $data = gettext("Unknown") . ": " . $data;
                    }
                }
                if ($tag == "0201") {
                    //Quality
                    if ($data == 2) {
                        $data = gettext("High");
                    } else {
                        $data = gettext("Unknown") . ": " . $data;
                    }
                }
                if ($tag == "0202") {
                    //Macro
                    if ($data == 0) {
                        $data = gettext("Normal");
                    } else {
                        $data = gettext("Unknown") . ": " . $data;
                    }
                }
            } else {
                if ($type == "UNDEFINED") {
                } else {
                    $data = bin2hex($data);
                    if ($intel == 1) {
                        $data = intel2Moto($data);
                    }
                }
            }
        }
    }
    return $data;
}
Example #3
0
File: exif.php Project: anqh/core
function formatData($type, $tag, $intel, $data)
{
    switch ($type) {
        case 'ASCII':
            if (($pos = strpos($data, chr(0))) !== false) {
                // Search for a null byte and stop there.
                $data = substr($data, 0, $pos);
            }
            if ($tag == '010f') {
                $data = ucwords(strtolower(trim($data)));
            }
            // Format certain kinds of strings nicely (Camera make etc.)
            break;
        case 'URATIONAL':
        case 'SRATIONAL':
            switch ($tag) {
                case '011a':
                    // XResolution
                // XResolution
                case '011b':
                    // YResolution
                    $data = round(unRational($data, $type, $intel)) . ' dots per ResolutionUnit';
                    break;
                case '829a':
                    // Exposure Time
                    $data = formatExposure(unRational($data, $type, $intel));
                    break;
                case '829d':
                    // FNumber
                    $data = 'f/' . unRational($data, $type, $intel);
                    break;
                case '9204':
                    // ExposureBiasValue
                    $data = round(unRational($data, $type, $intel), 2) . ' EV';
                    break;
                case '9205':
                    // ApertureValue
                // ApertureValue
                case '9202':
                    // MaxApertureValue
                    // ApertureValue is given in the APEX Mode. Many thanks to Matthieu Froment for this code
                    // The formula is : Aperture = 2*log2(FNumber) <=> FNumber = e((Aperture.ln(2))/2)
                    $datum = exp(unRational($data, $type, $intel) * log(2) / 2);
                    $data = round($datum, 1);
                    // Focal is given with a precision of 1 digit.
                    $data = 'f/' . $datum;
                    break;
                case '920a':
                    // FocalLength
                    $data = unRational($data, $type, $intel) . ' mm';
                    break;
                case '9201':
                    // ShutterSpeedValue
                    // The ShutterSpeedValue is given in the APEX mode. Many thanks to Matthieu Froment for this code
                    // The formula is : Shutter = - log2(exposureTime) (Appendix C of EXIF spec.)
                    // Where shutter is in APEX, log2(exposure) = ln(exposure)/ln(2)
                    // So final formula is : exposure = exp(-ln(2).shutter)
                    // The formula can be developed : exposure = 1/(exp(ln(2).shutter))
                    $datum = exp(unRational($data, $type, $intel) * log(2));
                    if ($datum != 0) {
                        $datum = 1 / $datum;
                    }
                    $data = formatExposure($datum);
                    break;
                default:
                    $data = unRational($data, $type, $intel);
                    break;
            }
            break;
        case 'USHORT':
        case 'SSHORT':
        case 'ULONG':
        case 'SLONG':
        case 'FLOAT':
        case 'DOUBLE':
            $data = rational($data, $type, $intel);
            switch ($tag) {
                case '0112':
                    // Orientation
                    // Example of how all of these tag formatters should be...
                    switch ($data) {
                        case 0:
                            // not set, presume normal
                        // not set, presume normal
                        case 1:
                            $data = gettext('1: Normal (0 deg)');
                            break;
                        case 2:
                            $data = gettext('2: Mirrored');
                            break;
                        case 3:
                            $data = gettext('3: Upside-down');
                            break;
                        case 4:
                            $data = gettext('4: Upside-down Mirrored');
                            break;
                        case 5:
                            $data = gettext('5: 90 deg CW Mirrored');
                            break;
                        case 6:
                            $data = gettext('6: 90 deg CCW');
                            break;
                        case 7:
                            $data = gettext('7: 90 deg CCW Mirrored');
                            break;
                        case 8:
                            $data = gettext('8: 90 deg CW');
                            break;
                        default:
                            $data = sprintf(gettext('%d: Unknown'), $data);
                            break;
                    }
                    break;
                case '0128':
                    // ResolutionUnit
                // ResolutionUnit
                case 'a210':
                    // FocalPlaneResolutionUnit
                // FocalPlaneResolutionUnit
                case '0128':
                    // ThumbnailResolutionUnit
                    switch ($data) {
                        case 1:
                            $data = gettext('No Unit');
                            break;
                        case 2:
                            $data = gettext('Inch');
                            break;
                        case 3:
                            $data = gettext('Centimeter');
                            break;
                    }
                    break;
                case '0213':
                    // YCbCrPositioning
                    switch ($data) {
                        case 1:
                            $data = gettext('Center of Pixel Array');
                            break;
                        case 2:
                            $data = gettext('Datum Point');
                            break;
                    }
                    break;
                case '8822':
                    // ExposureProgram
                    switch ($data) {
                        case 1:
                            $data = gettext('Manual');
                            break;
                        case 2:
                            $data = gettext('Program');
                            break;
                        case 3:
                            $data = gettext('Aperture Priority');
                            break;
                        case 4:
                            $data = gettext('Shutter Priority');
                            break;
                        case 5:
                            $data = gettext('Program Creative');
                            break;
                        case 6:
                            $data = gettext('Program Action');
                            break;
                        case 7:
                            $data = gettext('Portrait');
                            break;
                        case 8:
                            $data = gettext('Landscape');
                            break;
                        default:
                            $data = gettext('Unknown') . ': ' . $data;
                            break;
                    }
                    break;
                case '9207':
                    // MeteringMode
                    switch ($data) {
                        case 1:
                            $data = gettext('Average');
                            break;
                        case 2:
                            $data = gettext('Center Weighted Average');
                            break;
                        case 3:
                            $data = gettext('Spot');
                            break;
                        case 4:
                            $data = gettext('Multi-Spot');
                            break;
                        case 5:
                            $data = gettext('Pattern');
                            break;
                        case 6:
                            $data = gettext('Partial');
                            break;
                        case 255:
                            $data = gettext('Other');
                            break;
                        default:
                            $data = gettext('Unknown') . ': ' . $data;
                            break;
                    }
                    break;
                case '9208':
                    // LightSource
                    switch ($data) {
                        case 1:
                            $data = gettext('Daylight');
                            break;
                        case 2:
                            $data = gettext('Fluorescent');
                            break;
                        case 3:
                            $data = gettext('Tungsten');
                            break;
                            // 3 Tungsten (Incandescent light)
                            // 4 Flash
                            // 9 Fine Weather
                        // 3 Tungsten (Incandescent light)
                        // 4 Flash
                        // 9 Fine Weather
                        case 10:
                            $data = gettext('Flash');
                            break;
                            // 10 Cloudy Weather
                            // 11 Shade
                            // 12 Daylight Fluorescent (D 5700 - 7100K)
                            // 13 Day White Fluorescent (N 4600 - 5400K)
                            // 14 Cool White Fluorescent (W 3900 -4500K)
                            // 15 White Fluorescent (WW 3200 - 3700K)
                            // 10 Flash
                        // 10 Cloudy Weather
                        // 11 Shade
                        // 12 Daylight Fluorescent (D 5700 - 7100K)
                        // 13 Day White Fluorescent (N 4600 - 5400K)
                        // 14 Cool White Fluorescent (W 3900 -4500K)
                        // 15 White Fluorescent (WW 3200 - 3700K)
                        // 10 Flash
                        case 17:
                            $data = gettext('Standard Light A');
                            break;
                        case 18:
                            $data = gettext('Standard Light B');
                            break;
                        case 19:
                            $data = gettext('Standard Light C');
                            break;
                        case 20:
                            $data = gettext('D55');
                            break;
                        case 21:
                            $data = gettext('D65');
                            break;
                        case 22:
                            $data = gettext('D75');
                            break;
                        case 23:
                            $data = gettext('D50');
                            break;
                        case 24:
                            $data = gettext('ISO Studio Tungsten');
                            break;
                        case 255:
                            $data = gettext('Other');
                            break;
                        default:
                            $data = gettext('Unknown') . ': ' . $data;
                            break;
                    }
                    break;
                case '9209':
                    // Flash
                    switch ($data) {
                        case 0:
                            $data = gettext('No Flash');
                            break;
                        case 1:
                            $data = gettext('Flash');
                            break;
                        case 5:
                            $data = gettext('Flash, strobe return light not detected');
                            break;
                        case 7:
                            $data = gettext('Flash, strobe return light detected');
                            break;
                        case 9:
                            $data = gettext('Compulsory Flash');
                            break;
                        case 13:
                            $data = gettext('Compulsory Flash, Return light not detected');
                            break;
                        case 15:
                            $data = gettext('Compulsory Flash, Return light detected');
                            break;
                        case 16:
                            $data = gettext('No Flash');
                            break;
                        case 24:
                            $data = gettext('No Flash');
                            break;
                        case 25:
                            $data = gettext('Flash, Auto-Mode');
                            break;
                        case 29:
                            $data = gettext('Flash, Auto-Mode, Return light not detected');
                            break;
                        case 31:
                            $data = gettext('Flash, Auto-Mode, Return light detected');
                            break;
                        case 32:
                            $data = gettext('No Flash');
                            break;
                        case 65:
                            $data = gettext('Red Eye');
                            break;
                        case 69:
                            $data = gettext('Red Eye, Return light not detected');
                            break;
                        case 71:
                            $data = gettext('Red Eye, Return light detected');
                            break;
                        case 73:
                            $data = gettext('Red Eye, Compulsory Flash');
                            break;
                        case 77:
                            $data = gettext('Red Eye, Compulsory Flash, Return light not detected');
                            break;
                        case 79:
                            $data = gettext('Red Eye, Compulsory Flash, Return light detected');
                            break;
                        case 89:
                            $data = gettext('Red Eye, Auto-Mode');
                            break;
                        case 93:
                            $data = gettext('Red Eye, Auto-Mode, Return light not detected');
                            break;
                        case 95:
                            $data = gettext('Red Eye, Auto-Mode, Return light detected');
                            break;
                        default:
                            $data = gettext('Unknown') . ': ' . $data;
                            break;
                    }
                    break;
                case 'a001':
                    // ColorSpace
                    if ($data == 1) {
                        $data = gettext('sRGB');
                    } else {
                        $data = gettext('Uncalibrated');
                    }
                    break;
                case 'a002':
                    // ExifImageWidth
                // ExifImageWidth
                case 'a003':
                    // ExifImageHeight
                    $data = $data . ' ' . gettext('pixels');
                    break;
                case '0103':
                    // Compression
                    switch ($data) {
                        case 1:
                            $data = gettext('No Compression');
                            break;
                        case 6:
                            $data = gettext('Jpeg Compression');
                            break;
                        default:
                            $data = gettext('Unknown') . ': ' . $data;
                            break;
                    }
                    break;
                case 'a217':
                    // SensingMethod
                    switch ($data) {
                        case 1:
                            $data = gettext('Not defined');
                            break;
                        case 2:
                            $data = gettext('One Chip Color Area Sensor');
                            break;
                        case 3:
                            $data = gettext('Two Chip Color Area Sensor');
                            break;
                        case 4:
                            $data = gettext('Three Chip Color Area Sensor');
                            break;
                        case 5:
                            $data = gettext('Color Sequential Area Sensor');
                            break;
                        case 7:
                            $data = gettext('Trilinear Sensor');
                            break;
                        case 8:
                            $data = gettext('Color Sequential Linear Sensor');
                            break;
                        default:
                            $data = gettext('Unknown') . ': ' . $data;
                            break;
                    }
                    break;
                case '0106':
                    // PhotometricInterpretation
                    switch ($data) {
                        case 1:
                            $data = gettext('Monochrome');
                            break;
                        case 2:
                            $data = gettext('RGB');
                            break;
                        case 6:
                            $data = gettext('YCbCr');
                            break;
                        default:
                            $data = gettext('Unknown') . ': ' . $data;
                            break;
                    }
                    break;
                    //case "a408":	// Contrast
                    //case "a40a":	//Sharpness
                    //	switch($data) {
                    //		case 0: $data="Normal"; break;
                    //		case 1: $data="Soft"; break;
                    //		case 2: $data="Hard"; break;
                    //		default: $data="Unknown"; break;
                    //	}
                    //	break;
                    //case "a409":	// Saturation
                    //	switch($data) {
                    //		case 0: $data="Normal"; break;
                    //		case 1: $data="Low saturation"; break;
                    //		case 2: $data="High saturation"; break;
                    //		default: $data="Unknown"; break;
                    //	}
                    //	break;
                    //case "a402":	// Exposure Mode
                    //	switch($data) {
                    //		case 0: $data="Auto exposure"; break;
                    //		case 1: $data="Manual exposure"; break;
                    //		case 2: $data="Auto bracket"; break;
                    //		default: $data="Unknown"; break;
                    //	}
                    //	break;
            }
            break;
        case 'UNDEFINED':
            switch ($tag) {
                case '9000':
                    // ExifVersion
                // ExifVersion
                case 'a000':
                    // FlashPixVersion
                // FlashPixVersion
                case '0002':
                    // InteroperabilityVersion
                    $data = gettext('version') . ' ' . $data / 100;
                    break;
                case 'a300':
                    // FileSource
                    $data = bin2hex($data);
                    $data = str_replace('00', '', $data);
                    $data = str_replace('03', gettext('Digital Still Camera'), $data);
                    break;
                case 'a301':
                    // SceneType
                    $data = bin2hex($data);
                    $data = str_replace('00', '', $data);
                    $data = str_replace('01', gettext('Directly Photographed'), $data);
                    break;
                case '9101':
                    // ComponentsConfiguration
                    $data = bin2hex($data);
                    $data = str_replace('01', 'Y', $data);
                    $data = str_replace('02', 'Cb', $data);
                    $data = str_replace('03', 'Cr', $data);
                    $data = str_replace('04', 'R', $data);
                    $data = str_replace('05', 'G', $data);
                    $data = str_replace('06', 'B', $data);
                    $data = str_replace('00', '', $data);
                    break;
                    //case "9286":	//UserComment
                    //	$encoding	= rtrim(substr($data, 0, 8));
                    //	$data		= rtrim(substr($data, 8));
                    //	break;
            }
            break;
        default:
            $data = bin2hex($data);
            if ($intel == 1) {
                $data = intel2Moto($data);
            }
            break;
    }
    return $data;
}
Example #4
0
function formatGPSData($type, $tag, $intel, $data)
{
    if ($type == "ASCII") {
        if ($tag == "0001" || $tag == "0003") {
            // Latitude Reference, Longitude Reference
            $data = $data[1] == $data[2] && $data[1] == $data[3] ? $data[0] : $data;
        }
    } else {
        if ($type == "URATIONAL" || $type == "SRATIONAL") {
            if ($tag == "0002" || $tag == "0004" || $tag == '0007') {
                //Latitude, Longitude, Time
                $datum = array();
                for ($i = 0; $i < strlen($data); $i = $i + 8) {
                    array_push($datum, substr($data, $i, 8));
                }
                $hour = unRational($datum[0], $type, $intel);
                $minutes = unRational($datum[1], $type, $intel);
                $seconds = unRational($datum[2], $type, $intel);
                if ($tag == "0007") {
                    //Time
                    $data = $hour . ":" . $minutes . ":" . $seconds;
                } else {
                    $data = $hour + $minutes / 60 + $seconds / 3600;
                }
            } else {
                $data = unRational($data, $type, $intel);
                if ($tag == "0006") {
                    $data .= 'm';
                }
            }
        } else {
            if ($type == "USHORT" || $type == "SSHORT" || $type == "ULONG" || $type == "SLONG" || $type == "FLOAT" || $type == "DOUBLE") {
                $data = rational($data, $type, $intel);
            } else {
                if ($type == "UNDEFINED") {
                } else {
                    if ($type == "UBYTE") {
                        $data = bin2hex($data);
                        if ($intel == 1) {
                            $num = intel2Moto($data);
                        }
                        if ($tag == "0000") {
                            // VersionID
                            $data = hexdec(substr($data, 0, 2)) . "." . hexdec(substr($data, 2, 2)) . "." . hexdec(substr($data, 4, 2)) . "." . hexdec(substr($data, 6, 2));
                        } else {
                            if ($tag == "0005") {
                                // Altitude Reference
                                if ($data == "00000000") {
                                    $data = '+';
                                } else {
                                    if ($data == "01000000") {
                                        $data = '-';
                                    }
                                }
                            }
                        }
                    } else {
                        $data = bin2hex($data);
                        if ($intel == 1) {
                            $data = intel2Moto($data);
                        }
                    }
                }
            }
        }
    }
    return $data;
}
function formatFujifilmData($type, $tag, $intel, $data)
{
    if ($type == "ASCII") {
    } else {
        if ($type == "URATIONAL" || $type == "SRATIONAL") {
            $data = unRational($data, $type, $intel);
            if ($tag == "1011") {
                //FlashStrength
                $data = $data . " EV";
            }
        } else {
            if ($type == "USHORT" || $type == "SSHORT" || $type == "ULONG" || $type == "SLONG" || $type == "FLOAT" || $type == "DOUBLE") {
                $data = rational($data, $type, $intel);
                if ($tag == "1001") {
                    //Sharpness
                    if ($data == 1) {
                        $data = gettext("Soft");
                    } else {
                        if ($data == 2) {
                            $data = gettext("Soft");
                        } else {
                            if ($data == 3) {
                                $data = gettext("Normal");
                            } else {
                                if ($data == 4) {
                                    $data = gettext("Hard");
                                } else {
                                    if ($data == 5) {
                                        $data = gettext("Hard");
                                    } else {
                                        $data = gettext("Unknown") . ": " . $data;
                                    }
                                }
                            }
                        }
                    }
                }
                if ($tag == "1002") {
                    //WhiteBalance
                    if ($data == 0) {
                        $data = gettext("Auto");
                    } else {
                        if ($data == 256) {
                            $data = gettext("Daylight");
                        } else {
                            if ($data == 512) {
                                $data = gettext("Cloudy");
                            } else {
                                if ($data == 768) {
                                    $data = gettext("DaylightColor-fluorescence");
                                } else {
                                    if ($data == 769) {
                                        $data = gettext("DaywhiteColor-fluorescence");
                                    } else {
                                        if ($data == 770) {
                                            $data = gettext("White-fluorescence");
                                        } else {
                                            if ($data == 1024) {
                                                $data = gettext("Incandescence");
                                            } else {
                                                if ($data == 3840) {
                                                    $data = gettext("Custom");
                                                } else {
                                                    $data = gettext("Unknown") . ": " . $data;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if ($tag == "1003") {
                    //Color
                    if ($data == 0) {
                        $data = gettext("Chroma Saturation Normal(STD)");
                    } else {
                        if ($data == 256) {
                            $data = gettext("Chroma Saturation High");
                        } else {
                            if ($data == 512) {
                                $data = gettext("Chroma Saturation Low(ORG)");
                            } else {
                                $data = gettext("Unknown: ") . $data;
                            }
                        }
                    }
                }
                if ($tag == "1004") {
                    //Tone
                    if ($data == 0) {
                        $data = gettext("Contrast Normal(STD)");
                    } else {
                        if ($data == 256) {
                            $data = gettext("Contrast High(HARD)");
                        } else {
                            if ($data == 512) {
                                $data = gettext("Contrast Low(ORG)");
                            } else {
                                $data = gettext("Unknown: ") . $data;
                            }
                        }
                    }
                }
                if ($tag == "1010") {
                    //FlashMode
                    if ($data == 0) {
                        $data = gettext("Auto");
                    } else {
                        if ($data == 1) {
                            $data = gettext("On");
                        } else {
                            if ($data == 2) {
                                $data = gettext("Off");
                            } else {
                                if ($data == 3) {
                                    $data = gettext("Red-Eye Reduction");
                                } else {
                                    $data = gettext("Unknown: ") . $data;
                                }
                            }
                        }
                    }
                }
                if ($tag == "1020") {
                    //Macro
                    if ($data == 0) {
                        $data = gettext("Off");
                    } else {
                        if ($data == 1) {
                            $data = gettext("On");
                        } else {
                            $data = gettext("Unknown: ") . $data;
                        }
                    }
                }
                if ($tag == "1021") {
                    //FocusMode
                    if ($data == 0) {
                        $data = gettext("Auto");
                    } else {
                        if ($data == 1) {
                            $data = gettext("Manual");
                        } else {
                            $data = gettext("Unknown: ") . $data;
                        }
                    }
                }
                if ($tag == "1030") {
                    //SlowSync
                    if ($data == 0) {
                        $data = gettext("Off");
                    } else {
                        if ($data == 1) {
                            $data = gettext("On");
                        } else {
                            $data = gettext("Unknown: ") . $data;
                        }
                    }
                }
                if ($tag == "1031") {
                    //PictureMode
                    if ($data == 0) {
                        $data = gettext("Auto");
                    } else {
                        if ($data == 1) {
                            $data = gettext("Portrait");
                        } else {
                            if ($data == 2) {
                                $data = gettext("Landscape");
                            } else {
                                if ($data == 4) {
                                    $data = gettext("Sports");
                                } else {
                                    if ($data == 5) {
                                        $data = gettext("Night");
                                    } else {
                                        if ($data == 6) {
                                            $data = gettext("Program AE");
                                        } else {
                                            if ($data == 256) {
                                                $data = gettext("Aperture Priority AE");
                                            } else {
                                                if ($data == 512) {
                                                    $data = gettext("Shutter Priority");
                                                } else {
                                                    if ($data == 768) {
                                                        $data = gettext("Manual Exposure");
                                                    } else {
                                                        $data = gettext("Unknown: ") . $data;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if ($tag == "1100") {
                    //ContinuousTakingBracket
                    if ($data == 0) {
                        $data = gettext("Off");
                    } else {
                        if ($data == 1) {
                            $data = gettext("On");
                        } else {
                            $data = gettext("Unknown: ") . $data;
                        }
                    }
                }
                if ($tag == "1300") {
                    //BlurWarning
                    if ($data == 0) {
                        $data = gettext("No Warning");
                    } else {
                        if ($data == 1) {
                            $data = gettext("Warning");
                        } else {
                            $data = gettext("Unknown: ") . $data;
                        }
                    }
                }
                if ($tag == "1301") {
                    //FocusWarning
                    if ($data == 0) {
                        $data = gettext("Auto Focus Good");
                    } else {
                        if ($data == 1) {
                            $data = gettext("Out of Focus");
                        } else {
                            $data = gettext("Unknown: ") . $data;
                        }
                    }
                }
                if ($tag == "1302") {
                    //AEWarning
                    if ($data == 0) {
                        $data = gettext("AE Good");
                    } else {
                        if ($data == 1) {
                            $data = gettext("Over Exposure");
                        } else {
                            $data = gettext("Unknown: ") . $data;
                        }
                    }
                }
            } else {
                if ($type == "UNDEFINED") {
                } else {
                    $data = bin2hex($data);
                    if ($intel == 1) {
                        $data = intel2Moto($data);
                    }
                }
            }
        }
    }
    return $data;
}
Example #6
0
File: canon.php Project: anqh/core
function formatCanonData($type, $tag, $intel, $data, $exif, &$result)
{
    $place = 0;
    if ($type == "ASCII") {
        $result = $data = str_replace("", "", $data);
    } else {
        if ($type == "URATIONAL" || $type == "SRATIONAL") {
            $data = unRational($data, $type, $intel);
            if ($tag == "0204") {
                //DigitalZoom
                $data = $data . "x";
            }
        } else {
            if ($type == "USHORT" || $type == "SSHORT" || $type == "ULONG" || $type == "SLONG" || $type == "FLOAT" || $type == "DOUBLE") {
                $data = rational($data, $type, $intel);
                $result['RAWDATA'] = $data;
                if ($tag == "0001") {
                    //first chunk
                    $result['Bytes'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //0
                    if ($result['Bytes'] != strlen($data) / 2) {
                        return $result;
                    }
                    //Bad chunk
                    $result['Macro'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //1
                    switch ($result['Macro']) {
                        case 1:
                            $result['Macro'] = gettext("Macro");
                            break;
                        case 2:
                            $result['Macro'] = gettext("Normal");
                            break;
                        default:
                            $result['Macro'] = gettext("Unknown");
                    }
                    $result['SelfTimer'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //2
                    switch ($result['SelfTimer']) {
                        case 0:
                            $result['SelfTimer'] = gettext("Off");
                            break;
                        default:
                            $result['SelfTimer'] .= gettext("/10s");
                    }
                    $result['Quality'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //3
                    switch ($result['Quality']) {
                        case 2:
                            $result['Quality'] = gettext("Normal");
                            break;
                        case 3:
                            $result['Quality'] = gettext("Fine");
                            break;
                        case 5:
                            $result['Quality'] = gettext("Superfine");
                            break;
                        default:
                            $result['Quality'] = gettext("Unknown");
                    }
                    $result['Flash'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //4
                    switch ($result['Flash']) {
                        case 0:
                            $result['Flash'] = gettext("Off");
                            break;
                        case 1:
                            $result['Flash'] = gettext("Auto");
                            break;
                        case 2:
                            $result['Flash'] = gettext("On");
                            break;
                        case 3:
                            $result['Flash'] = gettext("Red Eye Reduction");
                            break;
                        case 4:
                            $result['Flash'] = gettext("Slow Synchro");
                            break;
                        case 5:
                            $result['Flash'] = gettext("Auto + Red Eye Reduction");
                            break;
                        case 6:
                            $result['Flash'] = gettext("On + Red Eye Reduction");
                            break;
                        case 16:
                            $result['Flash'] = gettext("External Flash");
                            break;
                        default:
                            $result['Flash'] = gettext("Unknown");
                    }
                    $result['DriveMode'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //5
                    switch ($result['DriveMode']) {
                        case 0:
                            $result['DriveMode'] = gettext("Single/Timer");
                            break;
                        case 1:
                            $result['DriveMode'] = gettext("Continuous");
                            break;
                        default:
                            $result['DriveMode'] = gettext("Unknown");
                    }
                    $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //6
                    $result['FocusMode'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //7
                    switch ($result['FocusMode']) {
                        case 0:
                            $result['FocusMode'] = gettext("One-Shot");
                            break;
                        case 1:
                            $result['FocusMode'] = gettext("AI Servo");
                            break;
                        case 2:
                            $result['FocusMode'] = gettext("AI Focus");
                            break;
                        case 3:
                            $result['FocusMode'] = gettext("Manual Focus");
                            break;
                        case 4:
                            $result['FocusMode'] = gettext("Single");
                            break;
                        case 5:
                            $result['FocusMode'] = gettext("Continuous");
                            break;
                        case 6:
                            $result['FocusMode'] = gettext("Manual Focus");
                            break;
                        default:
                            $result['FocusMode'] = gettext("Unknown");
                    }
                    $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //8
                    $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //9
                    $result['ImageSize'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //10
                    switch ($result['ImageSize']) {
                        case 0:
                            $result['ImageSize'] = gettext("Large");
                            break;
                        case 1:
                            $result['ImageSize'] = gettext("Medium");
                            break;
                        case 2:
                            $result['ImageSize'] = gettext("Small");
                            break;
                        default:
                            $result['ImageSize'] = gettext("Unknown");
                    }
                    $result['EasyShooting'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //11
                    switch ($result['EasyShooting']) {
                        case 0:
                            $result['EasyShooting'] = gettext("Full Auto");
                            break;
                        case 1:
                            $result['EasyShooting'] = gettext("Manual");
                            break;
                        case 2:
                            $result['EasyShooting'] = gettext("Landscape");
                            break;
                        case 3:
                            $result['EasyShooting'] = gettext("Fast Shutter");
                            break;
                        case 4:
                            $result['EasyShooting'] = gettext("Slow Shutter");
                            break;
                        case 5:
                            $result['EasyShooting'] = gettext("Night");
                            break;
                        case 6:
                            $result['EasyShooting'] = gettext("Black & White");
                            break;
                        case 7:
                            $result['EasyShooting'] = gettext("Sepia");
                            break;
                        case 8:
                            $result['EasyShooting'] = gettext("Portrait");
                            break;
                        case 9:
                            $result['EasyShooting'] = gettext("Sport");
                            break;
                        case 10:
                            $result['EasyShooting'] = gettext("Macro/Close-Up");
                            break;
                        case 11:
                            $result['EasyShooting'] = gettext("Pan Focus");
                            break;
                        default:
                            $result['EasyShooting'] = gettext("Unknown");
                    }
                    $result['DigitalZoom'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //12
                    switch ($result['DigitalZoom']) {
                        case 0:
                        case 65535:
                            $result['DigitalZoom'] = gettext("None");
                            break;
                        case 1:
                            $result['DigitalZoom'] = gettext("2x");
                            break;
                        case 2:
                            $result['DigitalZoom'] = gettext("4x");
                            break;
                        default:
                            $result['DigitalZoom'] = gettext("Unknown");
                    }
                    $result['Contrast'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //13
                    switch ($result['Contrast']) {
                        case 0:
                            $result['Contrast'] = gettext("Normal");
                            break;
                        case 1:
                            $result['Contrast'] = gettext("High");
                            break;
                        case 65535:
                            $result['Contrast'] = gettext("Low");
                            break;
                        default:
                            $result['Contrast'] = gettext("Unknown");
                    }
                    $result['Saturation'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //14
                    switch ($result['Saturation']) {
                        case 0:
                            $result['Saturation'] = gettext("Normal");
                            break;
                        case 1:
                            $result['Saturation'] = gettext("High");
                            break;
                        case 65535:
                            $result['Saturation'] = gettext("Low");
                            break;
                        default:
                            $result['Saturation'] = gettext("Unknown");
                    }
                    $result['Sharpness'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //15
                    switch ($result['Sharpness']) {
                        case 0:
                            $result['Sharpness'] = gettext("Normal");
                            break;
                        case 1:
                            $result['Sharpness'] = gettext("High");
                            break;
                        case 65535:
                            $result['Sharpness'] = gettext("Low");
                            break;
                        default:
                            $result['Sharpness'] = gettext("Unknown");
                    }
                    $result['ISO'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //16
                    switch ($result['ISO']) {
                        case 32767:
                        case 0:
                            $result['ISO'] = isset($exif['SubIFD']['ISOSpeedRatings']) ? $exif['SubIFD']['ISOSpeedRatings'] : 'Unknown';
                            break;
                        case 15:
                            $result['ISO'] = gettext("Auto");
                            break;
                        case 16:
                            $result['ISO'] = gettext("50");
                            break;
                        case 17:
                            $result['ISO'] = gettext("100");
                            break;
                        case 18:
                            $result['ISO'] = gettext("200");
                            break;
                        case 19:
                            $result['ISO'] = gettext("400");
                            break;
                        default:
                            $result['ISO'] = gettext("Unknown");
                    }
                    $result['MeteringMode'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //17
                    switch ($result['MeteringMode']) {
                        case 3:
                            $result['MeteringMode'] = gettext("Evaluative");
                            break;
                        case 4:
                            $result['MeteringMode'] = gettext("Partial");
                            break;
                        case 5:
                            $result['MeteringMode'] = gettext("Center-weighted");
                            break;
                        default:
                            $result['MeteringMode'] = gettext("Unknown");
                    }
                    $result['FocusType'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //18
                    switch ($result['FocusType']) {
                        case 0:
                            $result['FocusType'] = gettext("Manual");
                            break;
                        case 1:
                            $result['FocusType'] = gettext("Auto");
                            break;
                        case 3:
                            $result['FocusType'] = gettext("Close-up (Macro)");
                            break;
                        case 8:
                            $result['FocusType'] = gettext("Locked (Pan Mode)");
                            break;
                        default:
                            $result['FocusType'] = gettext("Unknown");
                    }
                    $result['AFPointSelected'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //19
                    switch ($result['AFPointSelected']) {
                        case 12288:
                            $result['AFPointSelected'] = gettext("Manual Focus");
                            break;
                        case 12289:
                            $result['AFPointSelected'] = gettext("Auto Selected");
                            break;
                        case 12290:
                            $result['AFPointSelected'] = gettext("Right");
                            break;
                        case 12291:
                            $result['AFPointSelected'] = gettext("Center");
                            break;
                        case 12292:
                            $result['AFPointSelected'] = gettext("Left");
                            break;
                        default:
                            $result['AFPointSelected'] = gettext("Unknown");
                    }
                    $result['ExposureMode'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //20
                    switch ($result['ExposureMode']) {
                        case 0:
                            $result['ExposureMode'] = gettext("EasyShoot");
                            break;
                        case 1:
                            $result['ExposureMode'] = gettext("Program");
                            break;
                        case 2:
                            $result['ExposureMode'] = gettext("Tv");
                            break;
                        case 3:
                            $result['ExposureMode'] = gettext("Av");
                            break;
                        case 4:
                            $result['ExposureMode'] = gettext("Manual");
                            break;
                        case 5:
                            $result['ExposureMode'] = gettext("Auto-DEP");
                            break;
                        default:
                            $result['ExposureMode'] = gettext("Unknown");
                    }
                    $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //21
                    $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //22
                    $result['LongFocalLength'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //23
                    $result['LongFocalLength'] .= " focal units";
                    $result['ShortFocalLength'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //24
                    $result['ShortFocalLength'] .= " focal units";
                    $result['FocalUnits'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //25
                    $result['FocalUnits'] .= " per mm";
                    $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //26
                    $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //27
                    $result['FlashActivity'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //28
                    switch ($result['FlashActivity']) {
                        case 0:
                            $result['FlashActivity'] = gettext("Flash Did Not Fire");
                            break;
                        case 1:
                            $result['FlashActivity'] = gettext("Flash Fired");
                            break;
                        default:
                            $result['FlashActivity'] = gettext("Unknown");
                    }
                    $result['FlashDetails'] = str_pad(base_convert(intel2Moto(substr($data, $place, 4)), 16, 2), 16, "0", STR_PAD_LEFT);
                    $place += 4;
                    //29
                    $flashDetails = array();
                    if (substr($result['FlashDetails'], 1, 1) == 1) {
                        $flashDetails[] = gettext('External E-TTL');
                    }
                    if (substr($result['FlashDetails'], 2, 1) == 1) {
                        $flashDetails[] = gettext('Internal Flash');
                    }
                    if (substr($result['FlashDetails'], 4, 1) == 1) {
                        $flashDetails[] = gettext('FP sync used');
                    }
                    if (substr($result['FlashDetails'], 8, 1) == 1) {
                        $flashDetails[] = gettext('2nd(rear)-curtain sync used');
                    }
                    if (substr($result['FlashDetails'], 12, 1) == 1) {
                        $flashDetails[] = gettext('1st curtain sync');
                    }
                    $result['FlashDetails'] = implode(",", $flashDetails);
                    $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //30
                    $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //31
                    $anotherFocusMode = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //32
                    if (strpos(strtoupper($exif['IFD0']['Model']), "G1") !== false) {
                        switch ($anotherFocusMode) {
                            case 0:
                                $result['FocusMode'] = gettext("Single");
                                break;
                            case 1:
                                $result['FocusMode'] = gettext("Continuous");
                                break;
                            default:
                                $result['FocusMode'] = gettext("Unknown");
                        }
                    }
                } else {
                    if ($tag == "0004") {
                        //second chunk
                        $result['Bytes'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //0
                        if ($result['Bytes'] != strlen($data) / 2) {
                            return $result;
                        }
                        //Bad chunk
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //1
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //2
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //3
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //4
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //5
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //6
                        $result['WhiteBalance'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //7
                        switch ($result['WhiteBalance']) {
                            case 0:
                                $result['WhiteBalance'] = gettext("Auto");
                                break;
                            case 1:
                                $result['WhiteBalance'] = gettext("Sunny");
                                break;
                            case 2:
                                $result['WhiteBalance'] = gettext("Cloudy");
                                break;
                            case 3:
                                $result['WhiteBalance'] = gettext("Tungsten");
                                break;
                            case 4:
                                $result['WhiteBalance'] = gettext("Fluorescent");
                                break;
                            case 5:
                                $result['WhiteBalance'] = gettext("Flash");
                                break;
                            case 6:
                                $result['WhiteBalance'] = gettext("Custom");
                                break;
                            default:
                                $result['WhiteBalance'] = gettext("Unknown");
                        }
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //8
                        $result['SequenceNumber'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //9
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //10
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //11
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //12
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //13
                        $result['AFPointUsed'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //14
                        $afPointUsed = array();
                        if ($result['AFPointUsed'] & 0x1) {
                            $afPointUsed[] = gettext("Right");
                        }
                        //bit 0
                        if ($result['AFPointUsed'] & 0x2) {
                            $afPointUsed[] = gettext("Center");
                        }
                        //bit 1
                        if ($result['AFPointUsed'] & 0x4) {
                            $afPointUsed[] = gettext("Left");
                        }
                        //bit 2
                        if ($result['AFPointUsed'] & 0x800) {
                            $afPointUsed[] = gettext("12");
                        }
                        //bit 12
                        if ($result['AFPointUsed'] & 0x1000) {
                            $afPointUsed[] = gettext("13");
                        }
                        //bit 13
                        if ($result['AFPointUsed'] & 0x2000) {
                            $afPointUsed[] = gettext("14");
                        }
                        //bit 14
                        if ($result['AFPointUsed'] & 0x4000) {
                            $afPointUsed[] = gettext("15");
                        }
                        //bit 15
                        $result['AFPointUsed'] = implode(",", $afPointUsed);
                        $result['FlashBias'] = intel2Moto(substr($data, $place, 4));
                        $place += 4;
                        //15
                        switch ($result['FlashBias']) {
                            case 'ffc0':
                                $result['FlashBias'] = "-2 EV";
                                break;
                            case 'ffcc':
                                $result['FlashBias'] = "-1.67 EV";
                                break;
                            case 'ffd0':
                                $result['FlashBias'] = "-1.5 EV";
                                break;
                            case 'ffd4':
                                $result['FlashBias'] = "-1.33 EV";
                                break;
                            case 'ffe0':
                                $result['FlashBias'] = "-1 EV";
                                break;
                            case 'ffec':
                                $result['FlashBias'] = "-0.67 EV";
                                break;
                            case 'fff0':
                                $result['FlashBias'] = "-0.5 EV";
                                break;
                            case 'fff4':
                                $result['FlashBias'] = "-0.33 EV";
                                break;
                            case '0000':
                                $result['FlashBias'] = "0 EV";
                                break;
                            case '000c':
                                $result['FlashBias'] = "0.33 EV";
                                break;
                            case '0010':
                                $result['FlashBias'] = "0.5 EV";
                                break;
                            case '0014':
                                $result['FlashBias'] = "0.67 EV";
                                break;
                            case '0020':
                                $result['FlashBias'] = "1 EV";
                                break;
                            case '002c':
                                $result['FlashBias'] = "1.33 EV";
                                break;
                            case '0030':
                                $result['FlashBias'] = "1.5 EV";
                                break;
                            case '0034':
                                $result['FlashBias'] = "1.67 EV";
                                break;
                            case '0040':
                                $result['FlashBias'] = "2 EV";
                                break;
                            default:
                                $result['FlashBias'] = gettext("Unknown");
                        }
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //16
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //17
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //18
                        $result['SubjectDistance'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //19
                        $result['SubjectDistance'] .= "/100 m";
                    } else {
                        if ($tag == "0008") {
                            //image number
                            if ($intel == 1) {
                                $data = intel2Moto($data);
                            }
                            $data = hexdec($data);
                            $result = round($data / 10000) . "-" . $data % 10000;
                        } else {
                            if ($tag == "000c") {
                                //camera serial number
                                if ($intel == 1) {
                                    $data = intel2Moto($data);
                                }
                                $data = hexdec($data);
                                $result = "#" . bin2hex(substr($data, 0, 16)) . substr($data, 16, 16);
                            }
                        }
                    }
                }
            } else {
                if ($type == "UNDEFINED") {
                } else {
                    $data = bin2hex($data);
                    if ($intel == 1) {
                        $data = intel2Moto($data);
                    }
                }
            }
        }
    }
    return $data;
}
function formatNikonData($type, $tag, $intel, $model, $data)
{
    switch ($type) {
        case "ASCII":
            break;
            // do nothing!
        // do nothing!
        case "URATIONAL":
        case "SRATIONAL":
            switch ($tag) {
                case '0084':
                    // LensInfo
                    $minFL = unRational(substr($data, 0, 8), $type, $intel);
                    $maxFL = unRational(substr($data, 8, 8), $type, $intel);
                    $minSP = unRational(substr($data, 16, 8), $type, $intel);
                    $maxSP = unRational(substr($data, 24, 8), $type, $intel);
                    if ($minFL == $maxFL) {
                        $data = sprintf('%0.0f f/%0.0f', $minFL, $minSP);
                    } elseif ($minSP == $maxSP) {
                        $data = sprintf('%0.0f-%0.0fmm f/%0.1f', $minFL, $maxFL, $minSP);
                    } else {
                        $data = sprintf('%0.0f-%0.0fmm f/%0.1f-%0.1f', $minFL, $maxFL, $minSP, $maxSP);
                    }
                    break;
                case "0085":
                    if ($model == 1) {
                        $data = unRational($data, $type, $intel) . " m";
                    }
                    //ManualFocusDistance
                    break;
                case "0086":
                    if ($model == 1) {
                        $data = unRational($data, $type, $intel) . "x";
                    }
                    //DigitalZoom
                    break;
                case "000a":
                    if ($model == 0) {
                        $data = unRational($data, $type, $intel) . "x";
                    }
                    //DigitalZoom
                    break;
                default:
                    $data = unRational($data, $type, $intel);
                    break;
            }
            break;
        case "USHORT":
        case $type == "SSHORT":
        case $type == "ULONG":
        case $type == "SLONG":
        case $type == "FLOAT":
        case $type == "DOUBLE":
            $data = rational($data, $type, $intel);
            switch ($tag) {
                case "0003":
                    if ($model == 0) {
                        //Quality
                        switch ($data) {
                            case 1:
                                $data = gettext("VGA Basic");
                                break;
                            case 2:
                                $data = gettext("VGA Normal");
                                break;
                            case 3:
                                $data = gettext("VGA Fine");
                                break;
                            case 4:
                                $data = gettext("SXGA Basic");
                                break;
                            case 5:
                                $data = gettext("SXGA Normal");
                                break;
                            case 6:
                                $data = gettext("SXGA Fine");
                                break;
                            default:
                                $data = gettext("Unknown") . ": " . $data;
                                break;
                        }
                    }
                    break;
                case "0004":
                    if ($model == 0) {
                        //Color
                        switch ($data) {
                            case 1:
                                $data = gettext("Color");
                                break;
                            case 2:
                                $data = gettext("Monochrome");
                                break;
                            default:
                                $data = gettext("Unknown") . ": " . $data;
                                break;
                        }
                    }
                    break;
                case "0005":
                    if ($model == 0) {
                        //Image Adjustment
                        switch ($data) {
                            case 0:
                                $data = gettext("Normal");
                                break;
                            case 1:
                                $data = gettext("Bright+");
                                break;
                            case 2:
                                $data = gettext("Bright-");
                                break;
                            case 3:
                                $data = gettext("Contrast+");
                                break;
                            case 4:
                                $data = gettext("Contrast-");
                                break;
                            default:
                                $data = gettext("Unknown") . ": " . $data;
                                break;
                        }
                    }
                    break;
                case "0006":
                    if ($model == 0) {
                        //CCD Sensitivity
                        switch ($data) {
                            case 0:
                                $data = "ISO-80";
                                break;
                            case 2:
                                $data = "ISO-160";
                                break;
                            case 4:
                                $data = "ISO-320";
                                break;
                            case 5:
                                $data = "ISO-100";
                                break;
                            default:
                                $data = gettext("Unknown") . ": " . $data;
                                break;
                        }
                    }
                    break;
                case "0007":
                    if ($model == 0) {
                        //White Balance
                        switch ($data) {
                            case 0:
                                $data = gettext("Auto");
                                break;
                            case 1:
                                $data = gettext("Preset");
                                break;
                            case 2:
                                $data = gettext("Daylight");
                                break;
                            case 3:
                                $data = gettext("Incandescence");
                                break;
                            case 4:
                                $data = gettext("Fluorescence");
                                break;
                            case 5:
                                $data = gettext("Cloudy");
                                break;
                            case 6:
                                $data = gettext("SpeedLight");
                                break;
                            default:
                                $data = gettext("Unknown") . ": " . $data;
                                break;
                        }
                    }
                    break;
                case "000b":
                    if ($model == 0) {
                        //Converter
                        switch ($data) {
                            case 0:
                                $data = gettext("None");
                                break;
                            case 1:
                                $data = gettext("Fisheye");
                                break;
                            default:
                                $data = gettext("Unknown") . ": " . $data;
                                break;
                        }
                    }
                    break;
            }
            break;
        case "UNDEFINED":
            switch ($tag) {
                case "0001":
                    if ($model == 1) {
                        $data = $data / 100;
                    }
                    break;
                    //Unknown (Version?)
                    break;
                case "0088":
                    if ($model == 1) {
                        //AF Focus Position
                        $temp = gettext("Center");
                        $data = bin2hex($data);
                        $data = str_replace("01", "Top", $data);
                        $data = str_replace("02", "Bottom", $data);
                        $data = str_replace("03", "Left", $data);
                        $data = str_replace("04", "Right", $data);
                        $data = str_replace("00", "", $data);
                        if (strlen($data) == 0) {
                            $data = $temp;
                        }
                    }
                    break;
            }
            break;
        default:
            $data = bin2hex($data);
            if ($intel == 1) {
                $data = intel2Moto($data);
            }
            switch ($tag) {
                case "0083":
                    if ($model == 1) {
                        //Lens Type
                        $data = hexdec(substr($data, 0, 2));
                        switch ($data) {
                            case 0:
                                $data = gettext("AF non D");
                                break;
                            case 1:
                                $data = gettext("Manual");
                                break;
                            case 2:
                                $data = "AF-D or AF-S";
                                break;
                            case 6:
                                $data = "AF-D G";
                                break;
                            case 10:
                                $data = "AF-D VR";
                                break;
                            case 14:
                                $data = "AF-D G VR";
                                break;
                            default:
                                $data = gettext("Unknown") . ": " . $data;
                                break;
                        }
                    }
                    break;
                case "0087":
                    if ($model == 1) {
                        //Flash type
                        $data = hexdec(substr($data, 0, 2));
                        if ($data == 0) {
                            $data = gettext("Did Not Fire");
                        } else {
                            if ($data == 4) {
                                $data = gettext("Unknown");
                            } else {
                                if ($data == 7) {
                                    $data = gettext("External");
                                } else {
                                    if ($data == 9) {
                                        $data = gettext("On Camera");
                                    } else {
                                        $data = gettext("Unknown") . ": " . $data;
                                    }
                                }
                            }
                        }
                    }
                    break;
            }
            break;
    }
    return $data;
}
Example #8
0
function formatFujifilmData($type, $tag, $intel, $data)
{
    if ($type == "ASCII") {
    } else {
        if ($type == "URATIONAL" || $type == "SRATIONAL") {
            $data = unRational($data, $type, $intel);
            if ($tag == "1011") {
                //FlashStrength
                $data = $data . " EV";
            }
        } else {
            if ($type == "USHORT" || $type == "SSHORT" || $type == "ULONG" || $type == "SLONG" || $type == "FLOAT" || $type == "DOUBLE") {
                $data = rational($data, $type, $intel);
                if ($tag == "1001") {
                    //Sharpness
                    if ($data == 1) {
                        $data = '!soft!';
                    } else {
                        if ($data == 2) {
                            $data = '!soft!';
                        } else {
                            if ($data == 3) {
                                $data = '!normal!';
                            } else {
                                if ($data == 4) {
                                    $data = '!hard!';
                                } else {
                                    if ($data == 5) {
                                        $data = '!hard!';
                                    } else {
                                        $data = '!unknown!' . ": " . $data;
                                    }
                                }
                            }
                        }
                    }
                }
                if ($tag == "1002") {
                    //WhiteBalance
                    if ($data == 0) {
                        $data = '!auto!';
                    } else {
                        if ($data == 256) {
                            $data = '!daylight!';
                        } else {
                            if ($data == 512) {
                                $data = '!cloudy!';
                            } else {
                                if ($data == 768) {
                                    $data = '!daylightcolor-fluorescence!';
                                } else {
                                    if ($data == 769) {
                                        $data = '!daywhitecolor-fluorescence!';
                                    } else {
                                        if ($data == 770) {
                                            $data = '!white-fluorescence!';
                                        } else {
                                            if ($data == 1024) {
                                                $data = '!incandescence!';
                                            } else {
                                                if ($data == 3840) {
                                                    $data = '!custom!';
                                                } else {
                                                    $data = '!unknown!' . ": " . $data;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if ($tag == "1003") {
                    //Color
                    if ($data == 0) {
                        $data = '!chroma saturation normal(std)!';
                    } else {
                        if ($data == 256) {
                            $data = '!chroma saturation high!';
                        } else {
                            if ($data == 512) {
                                $data = '!chroma saturation low(org)!';
                            } else {
                                $data = '!unknown!' . ':' . $data;
                            }
                        }
                    }
                }
                if ($tag == "1004") {
                    //Tone
                    if ($data == 0) {
                        $data = '!contrast normal(std)!';
                    } else {
                        if ($data == 256) {
                            $data = '!contrast high(hard)!';
                        } else {
                            if ($data == 512) {
                                $data = '!contrast low(org)!';
                            } else {
                                $data = '!unknown!' . ':' . $data;
                            }
                        }
                    }
                }
                if ($tag == "1010") {
                    //FlashMode
                    if ($data == 0) {
                        $data = '!auto!';
                    } else {
                        if ($data == 1) {
                            $data = '!on!';
                        } else {
                            if ($data == 2) {
                                $data = '!off!';
                            } else {
                                if ($data == 3) {
                                    $data = '!red-eye reduction!';
                                } else {
                                    $data = '!unknown!' . ':' . $data;
                                }
                            }
                        }
                    }
                }
                if ($tag == "1020") {
                    //Macro
                    if ($data == 0) {
                        $data = '!off!';
                    } else {
                        if ($data == 1) {
                            $data = '!on!';
                        } else {
                            $data = '!unknown!' . ':' . $data;
                        }
                    }
                }
                if ($tag == "1021") {
                    //FocusMode
                    if ($data == 0) {
                        $data = '!auto!';
                    } else {
                        if ($data == 1) {
                            $data = '!manual!';
                        } else {
                            $data = '!unknown!' . ':' . $data;
                        }
                    }
                }
                if ($tag == "1030") {
                    //SlowSync
                    if ($data == 0) {
                        $data = '!off!';
                    } else {
                        if ($data == 1) {
                            $data = '!on!';
                        } else {
                            $data = '!unknown!' . ':' . $data;
                        }
                    }
                }
                if ($tag == "1031") {
                    //PictureMode
                    if ($data == 0) {
                        $data = '!auto!';
                    } else {
                        if ($data == 1) {
                            $data = '!portrait!';
                        } else {
                            if ($data == 2) {
                                $data = '!landscape!';
                            } else {
                                if ($data == 4) {
                                    $data = '!sports!';
                                } else {
                                    if ($data == 5) {
                                        $data = '!night!';
                                    } else {
                                        if ($data == 6) {
                                            $data = '!program ae!';
                                        } else {
                                            if ($data == 256) {
                                                $data = '!aperture priority ae!';
                                            } else {
                                                if ($data == 512) {
                                                    $data = '!shutter priority!';
                                                } else {
                                                    if ($data == 768) {
                                                        $data = '!manual exposure!';
                                                    } else {
                                                        $data = '!unknown!' . ':' . $data;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if ($tag == "1100") {
                    //ContinuousTakingBracket
                    if ($data == 0) {
                        $data = '!off!';
                    } else {
                        if ($data == 1) {
                            $data = '!on!';
                        } else {
                            $data = '!unknown!' . ':' . $data;
                        }
                    }
                }
                if ($tag == "1300") {
                    //BlurWarning
                    if ($data == 0) {
                        $data = '!no warning!';
                    } else {
                        if ($data == 1) {
                            $data = '!warning!';
                        } else {
                            $data = '!unknown!' . ':' . $data;
                        }
                    }
                }
                if ($tag == "1301") {
                    //FocusWarning
                    if ($data == 0) {
                        $data = '!auto focus good!';
                    } else {
                        if ($data == 1) {
                            $data = '!out of focus!';
                        } else {
                            $data = '!unknown!' . ':' . $data;
                        }
                    }
                }
                if ($tag == "1302") {
                    //AEWarning
                    if ($data == 0) {
                        $data = '!ae good!';
                    } else {
                        if ($data == 1) {
                            $data = '!over exposure!';
                        } else {
                            $data = '!unknown!' . ':' . $data;
                        }
                    }
                }
            } else {
                if ($type == "UNDEFINED") {
                } else {
                    $data = bin2hex($data);
                    if ($intel == 1) {
                        $data = intel2Moto($data);
                    }
                }
            }
        }
    }
    return $data;
}
Example #9
0
function formatPanasonicData($type, $tag, $intel, $data)
{
    if ($type == "ASCII") {
    } else {
        if ($type == "UBYTE" || $type == "SBYTE") {
            $data = bin2hex($data);
            if ($intel == 1) {
                $data = intel2Moto($data);
            }
            $data = hexdec($data);
            if ($tag == "000f") {
                //AFMode
                if ($data == 256) {
                    $data = "9-area-focusing";
                } else {
                    if ($data == 16) {
                        $data = "1-area-focusing";
                    } else {
                        if ($data == 4096) {
                            $data = gettext("3-area-focusing (High speed)");
                        } else {
                            if ($data == 4112) {
                                $data = gettext("1-area-focusing (High speed)");
                            } else {
                                if ($data == 16) {
                                    $data = gettext("1-area-focusing");
                                } else {
                                    if ($data == 1) {
                                        $data = gettext("Spot-focusing");
                                    } else {
                                        $data = "Unknown (" . $data . ")";
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } else {
            if ($type == "URATIONAL" || $type == "SRATIONAL") {
                $data = unRational($data, $type, $intel);
            } else {
                if ($type == "USHORT" || $type == "SSHORT" || $type == "ULONG" || $type == "SLONG" || $type == "FLOAT" || $type == "DOUBLE") {
                    $data = rational($data, $type, $intel);
                    if ($tag == "0001") {
                        //Image Quality
                        if ($data == 2) {
                            $data = gettext("High");
                        } else {
                            if ($data == 3) {
                                $data = gettext("Standard");
                            } else {
                                if ($data == 6) {
                                    $data = gettext("Very High");
                                } else {
                                    if ($data == 7) {
                                        $data = gettext("RAW");
                                    } else {
                                        $data = gettext("Unknown") . " (" . $data . ")";
                                    }
                                }
                            }
                        }
                    }
                    if ($tag == "0003") {
                        //White Balance
                        if ($data == 1) {
                            $data = gettext("Auto");
                        } else {
                            if ($data == 2) {
                                $data = gettext("Daylight");
                            } else {
                                if ($data == 3) {
                                    $data = gettext("Cloudy");
                                } else {
                                    if ($data == 4) {
                                        $data = gettext("Halogen");
                                    } else {
                                        if ($data == 5) {
                                            $data = gettext("Manual");
                                        } else {
                                            if ($data == 8) {
                                                $data = gettext("Flash");
                                            } else {
                                                if ($data == 10) {
                                                    $data = gettext("Black and White");
                                                } else {
                                                    if ($data == 11) {
                                                        $data = gettext("Manual");
                                                    } else {
                                                        $data = gettext("Unknown") . " (" . $data . ")";
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ($tag == "0007") {
                        //Focus Mode
                        if ($data == 1) {
                            $data = gettext("Auto");
                        } else {
                            if ($data == 2) {
                                $data = gettext("Manual");
                            } else {
                                if ($data == 4) {
                                    $data = gettext("Auto, Focus button");
                                } else {
                                    if ($data == 5) {
                                        $data = gettext("Auto, Continuous");
                                    } else {
                                        $data = gettext("Unknown") . " (" . $data . ")";
                                    }
                                }
                            }
                        }
                    }
                    if ($tag == "001a") {
                        //Image Stabilizer
                        if ($data == 2) {
                            $data = gettext("Mode 1");
                        } else {
                            if ($data == 3) {
                                $data = gettext("Off");
                            } else {
                                if ($data == 4) {
                                    $data = gettext("Mode 2");
                                } else {
                                    $data = gettext("Unknown") . " (" . $data . ")";
                                }
                            }
                        }
                    }
                    if ($tag == "001c") {
                        //Macro mode
                        if ($data == 1) {
                            $data = gettext("On");
                        } else {
                            if ($data == 2) {
                                $data = gettext("Off");
                            } else {
                                $data = gettext("Unknown") . " (" . $data . ")";
                            }
                        }
                    }
                    if ($tag == "001f") {
                        //Shooting Mode
                        if ($data == 1) {
                            $data = gettext("Normal");
                        } else {
                            if ($data == 2) {
                                $data = gettext("Portrait");
                            } else {
                                if ($data == 3) {
                                    $data = gettext("Scenery");
                                } else {
                                    if ($data == 4) {
                                        $data = gettext("Sports");
                                    } else {
                                        if ($data == 5) {
                                            $data = gettext("Night Portrait");
                                        } else {
                                            if ($data == 6) {
                                                $data = gettext("Program");
                                            } else {
                                                if ($data == 7) {
                                                    $data = gettext("Aperture Priority");
                                                } else {
                                                    if ($data == 8) {
                                                        $data = gettext("Shutter Priority");
                                                    } else {
                                                        if ($data == 9) {
                                                            $data = gettext("Macro");
                                                        } else {
                                                            if ($data == 11) {
                                                                $data = gettext("Manual");
                                                            } else {
                                                                if ($data == 13) {
                                                                    $data = gettext("Panning");
                                                                } else {
                                                                    if ($data == 14) {
                                                                        $data = gettext("Simple");
                                                                    } else {
                                                                        if ($data == 18) {
                                                                            $data = gettext("Fireworks");
                                                                        } else {
                                                                            if ($data == 19) {
                                                                                $data = gettext("Party");
                                                                            } else {
                                                                                if ($data == 20) {
                                                                                    $data = gettext("Snow");
                                                                                } else {
                                                                                    if ($data == 21) {
                                                                                        $data = gettext("Night Scenery");
                                                                                    } else {
                                                                                        if ($data == 22) {
                                                                                            $data = gettext("Food");
                                                                                        } else {
                                                                                            if ($data == 23) {
                                                                                                $data = gettext("Baby");
                                                                                            } else {
                                                                                                if ($data == 27) {
                                                                                                    $data = gettext("High Sensitivity");
                                                                                                } else {
                                                                                                    if ($data == 29) {
                                                                                                        $data = gettext("Underwater");
                                                                                                    } else {
                                                                                                        if ($data == 33) {
                                                                                                            $data = gettext("Pet");
                                                                                                        } else {
                                                                                                            $data = gettext("Unknown") . " (" . $data . ")";
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ($tag == "0020") {
                        //Audio
                        if ($data == 1) {
                            $data = gettext("Yes");
                        } else {
                            if ($data == 2) {
                                $data = gettext("No");
                            } else {
                                $data = gettext("Unknown") . " (" . $data . ")";
                            }
                        }
                    }
                    if ($tag == "0023") {
                        //White Balance Bias
                        $data = $data . " EV";
                    }
                    if ($tag == "0024") {
                        //Flash Bias
                        $data = $data;
                    }
                    if ($tag == "0028") {
                        //Colour Effect
                        if ($data == 1) {
                            $data = gettext("Off");
                        } else {
                            if ($data == 2) {
                                $data = gettext("Warm");
                            } else {
                                if ($data == 3) {
                                    $data = gettext("Cool");
                                } else {
                                    if ($data == 4) {
                                        $data = gettext("Black and White");
                                    } else {
                                        if ($data == 5) {
                                            $data = gettext("Sepia");
                                        } else {
                                            $data = gettext("Unknown") . " (" . $data . ")";
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ($tag == "002a") {
                        //Burst Mode
                        if ($data == 0) {
                            $data = gettext("Off");
                        } else {
                            if ($data == 1) {
                                $data = gettext("Low/High Quality");
                            } else {
                                if ($data == 2) {
                                    $data = gettext("Infinite");
                                } else {
                                    $data = gettext("Unknown") . " (" . $data . ")";
                                }
                            }
                        }
                    }
                    if ($tag == "002c") {
                        //Contrast
                        if ($data == 0) {
                            $data = gettext("Standard");
                        } else {
                            if ($data == 1) {
                                $data = gettext("Low");
                            } else {
                                if ($data == 2) {
                                    $data = gettext("High");
                                } else {
                                    $data = gettext("Unknown") . " (" . $data . ")";
                                }
                            }
                        }
                    }
                    if ($tag == "002d") {
                        //Noise Reduction
                        if ($data == 0) {
                            $data = gettext("Standard");
                        } else {
                            if ($data == 1) {
                                $data = gettext("Low");
                            } else {
                                if ($data == 2) {
                                    $data = gettext("High");
                                } else {
                                    $data = gettext("Unknown") . " (" . $data . ")";
                                }
                            }
                        }
                    }
                    if ($tag == "002e") {
                        //Self Timer
                        if ($data == 1) {
                            $data = gettext("Off");
                        } else {
                            if ($data == 2) {
                                $data = gettext("10s");
                            } else {
                                if ($data == 3) {
                                    $data = gettext("2s");
                                } else {
                                    $data = gettext("Unknown") . " (" . $data . ")";
                                }
                            }
                        }
                    }
                    if ($tag == "0030") {
                        //Rotation
                        if ($data == 1) {
                            $data = gettext("Horizontal (normal)");
                        } else {
                            if ($data == 6) {
                                $data = gettext("Rotate 90 CW");
                            } else {
                                if ($data == 8) {
                                    $data = gettext("Rotate 270 CW");
                                } else {
                                    $data = gettext("Unknown") . " (" . $data . ")";
                                }
                            }
                        }
                    }
                    if ($tag == "0032") {
                        //Color Mode
                        if ($data == 0) {
                            $data = gettext("Normal");
                        } else {
                            if ($data == 1) {
                                $data = gettext("Natural");
                            } else {
                                $data = gettext("Unknown") . " (" . $data . ")";
                            }
                        }
                    }
                    if ($tag == "0036") {
                        //Travel Day
                        $data = $data;
                    }
                } else {
                    if ($type == "UNDEFINED") {
                    } else {
                        $data = bin2hex($data);
                        if ($intel == 1) {
                            $data = intel2Moto($data);
                        }
                    }
                }
            }
        }
    }
    return $data;
}
Example #10
0
function formatCanonData($type, $tag, $intel, $data, $exif, &$result)
{
    $place = 0;
    if ($type == "ASCII") {
        $result = $data = str_replace("", "", $data);
    } else {
        if ($type == "URATIONAL" || $type == "SRATIONAL") {
            $data = unRational($data, $type, $intel);
            if ($tag == "0204") {
                //DigitalZoom
                $data = $data . "x";
            }
        } else {
            if ($type == "USHORT" || $type == "SSHORT" || $type == "ULONG" || $type == "SLONG" || $type == "FLOAT" || $type == "DOUBLE") {
                $data = rational($data, $type, $intel);
                $result['RAWDATA'] = $data;
                if ($tag == "0001") {
                    //first chunk
                    $result['Bytes'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //0
                    if ($result['Bytes'] != strlen($data) / 2) {
                        return $result;
                    }
                    //Bad chunk
                    $result['Macro'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //1
                    switch ($result['Macro']) {
                        case 1:
                            $result['Macro'] = '!macro!';
                            break;
                        case 2:
                            $result['Macro'] = '!normal!';
                            break;
                        default:
                            $result['Macro'] = '!unknown!';
                    }
                    $result['SelfTimer'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //2
                    switch ($result['SelfTimer']) {
                        case 0:
                            $result['SelfTimer'] = '!off!';
                            break;
                        default:
                            $result['SelfTimer'] .= "/10s";
                    }
                    $result['Quality'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //3
                    switch ($result['Quality']) {
                        case 2:
                            $result['Quality'] = '!normal!';
                            break;
                        case 3:
                            $result['Quality'] = '!fine!';
                            break;
                        case 5:
                            $result['Quality'] = '!superfine!';
                            break;
                        default:
                            $result['Quality'] = '!unknown!';
                    }
                    $result['Flash'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //4
                    switch ($result['Flash']) {
                        case 0:
                            $result['Flash'] = '!off!';
                            break;
                        case 1:
                            $result['Flash'] = '!auto!';
                            break;
                        case 2:
                            $result['Flash'] = '!on!';
                            break;
                        case 3:
                            $result['Flash'] = '!red eye reduction!';
                            break;
                        case 4:
                            $result['Flash'] = '!slow synchro!';
                            break;
                        case 5:
                            $result['Flash'] = '!auto + red eye reduction!';
                            break;
                        case 6:
                            $result['Flash'] = '!on + red eye reduction!';
                            break;
                        case 16:
                            $result['Flash'] = '!external flash!';
                            break;
                        default:
                            $result['Flash'] = '!unknown!';
                    }
                    $result['DriveMode'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //5
                    switch ($result['DriveMode']) {
                        case 0:
                            $result['DriveMode'] = '!single/timer!';
                            break;
                        case 1:
                            $result['DriveMode'] = '!continuous!';
                            break;
                        default:
                            $result['DriveMode'] = '!unknown!';
                    }
                    $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //6
                    $result['FocusMode'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //7
                    switch ($result['FocusMode']) {
                        case 0:
                            $result['FocusMode'] = '!one-shot!';
                            break;
                        case 1:
                            $result['FocusMode'] = '!ai servo!';
                            break;
                        case 2:
                            $result['FocusMode'] = '!ai focus!';
                            break;
                        case 3:
                            $result['FocusMode'] = '!manual focus!';
                            break;
                        case 4:
                            $result['FocusMode'] = '!single!';
                            break;
                        case 5:
                            $result['FocusMode'] = '!continuous!';
                            break;
                        case 6:
                            $result['FocusMode'] = '!manual focus!';
                            break;
                        default:
                            $result['FocusMode'] = '!unknown!';
                    }
                    $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //8
                    $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //9
                    $result['ImageSize'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //10
                    switch ($result['ImageSize']) {
                        case 0:
                            $result['ImageSize'] = '!large!';
                            break;
                        case 1:
                            $result['ImageSize'] = '!medium!';
                            break;
                        case 2:
                            $result['ImageSize'] = '!small!';
                            break;
                        default:
                            $result['ImageSize'] = '!unknown!';
                    }
                    $result['EasyShooting'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //11
                    switch ($result['EasyShooting']) {
                        case 0:
                            $result['EasyShooting'] = '!full auto!';
                            break;
                        case 1:
                            $result['EasyShooting'] = '!manual!';
                            break;
                        case 2:
                            $result['EasyShooting'] = '!landscape!';
                            break;
                        case 3:
                            $result['EasyShooting'] = '!fast shutter!';
                            break;
                        case 4:
                            $result['EasyShooting'] = '!slow shutter!';
                            break;
                        case 5:
                            $result['EasyShooting'] = '!night!';
                            break;
                        case 6:
                            $result['EasyShooting'] = '!black & white!';
                            break;
                        case 7:
                            $result['EasyShooting'] = '!sepia!';
                            break;
                        case 8:
                            $result['EasyShooting'] = '!portrait!';
                            break;
                        case 9:
                            $result['EasyShooting'] = '!sport!';
                            break;
                        case 10:
                            $result['EasyShooting'] = '!macro/close-up!';
                            break;
                        case 11:
                            $result['EasyShooting'] = '!pan focus!';
                            break;
                        default:
                            $result['EasyShooting'] = '!unknown!';
                    }
                    $result['DigitalZoom'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //12
                    switch ($result['DigitalZoom']) {
                        case 0:
                        case 65535:
                            $result['DigitalZoom'] = '!none!';
                            break;
                        case 1:
                            $result['DigitalZoom'] = "2x";
                            break;
                        case 2:
                            $result['DigitalZoom'] = "4x";
                            break;
                        default:
                            $result['DigitalZoom'] = '!unknown!';
                    }
                    $result['Contrast'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //13
                    switch ($result['Contrast']) {
                        case 0:
                            $result['Contrast'] = '!normal!';
                            break;
                        case 1:
                            $result['Contrast'] = '!high!';
                            break;
                        case 65535:
                            $result['Contrast'] = '!low!';
                            break;
                        default:
                            $result['Contrast'] = '!unknown!';
                    }
                    $result['Saturation'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //14
                    switch ($result['Saturation']) {
                        case 0:
                            $result['Saturation'] = '!normal!';
                            break;
                        case 1:
                            $result['Saturation'] = '!high!';
                            break;
                        case 65535:
                            $result['Saturation'] = '!low!';
                            break;
                        default:
                            $result['Saturation'] = '!unknown!';
                    }
                    $result['Sharpness'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //15
                    switch ($result['Sharpness']) {
                        case 0:
                            $result['Sharpness'] = '!normal!';
                            break;
                        case 1:
                            $result['Sharpness'] = '!high!';
                            break;
                        case 65535:
                            $result['Sharpness'] = '!low!';
                            break;
                        default:
                            $result['Sharpness'] = '!unknown!';
                    }
                    $result['ISO'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //16
                    switch ($result['ISO']) {
                        case 32767:
                        case 0:
                            $result['ISO'] = isset($exif['SubIFD']['ISOSpeedRatings']) ? $exif['SubIFD']['ISOSpeedRatings'] : '!unknown!';
                            break;
                        case 15:
                            $result['ISO'] = '!auto!';
                            break;
                        case 16:
                            $result['ISO'] = "50";
                            break;
                        case 17:
                            $result['ISO'] = "100";
                            break;
                        case 18:
                            $result['ISO'] = "200";
                            break;
                        case 19:
                            $result['ISO'] = "400";
                            break;
                        default:
                            $result['ISO'] = "Unknown";
                    }
                    $result['MeteringMode'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //17
                    switch ($result['MeteringMode']) {
                        case 3:
                            $result['MeteringMode'] = '!evaluative!';
                            break;
                        case 4:
                            $result['MeteringMode'] = '!partial!';
                            break;
                        case 5:
                            $result['MeteringMode'] = '!center-weighted!';
                            break;
                        default:
                            $result['MeteringMode'] = '!unknown!';
                    }
                    $result['FocusType'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //18
                    switch ($result['FocusType']) {
                        case 0:
                            $result['FocusType'] = '!manual!';
                            break;
                        case 1:
                            $result['FocusType'] = '!auto!';
                            break;
                        case 3:
                            $result['FocusType'] = '!close-up (macro)!';
                            break;
                        case 8:
                            $result['FocusType'] = '!locked (pan mode)!';
                            break;
                        default:
                            $result['FocusType'] = '!unknown!';
                    }
                    $result['AFPointSelected'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //19
                    switch ($result['AFPointSelected']) {
                        case 12288:
                            $result['AFPointSelected'] = '!manual focus!';
                            break;
                        case 12289:
                            $result['AFPointSelected'] = '!auto selected!';
                            break;
                        case 12290:
                            $result['AFPointSelected'] = '!right!';
                            break;
                        case 12291:
                            $result['AFPointSelected'] = '!center!';
                            break;
                        case 12292:
                            $result['AFPointSelected'] = '!left!';
                            break;
                        default:
                            $result['AFPointSelected'] = '!unknown!';
                    }
                    $result['ExposureMode'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //20
                    switch ($result['ExposureMode']) {
                        case 0:
                            $result['ExposureMode'] = '!easyshoot!';
                            break;
                        case 1:
                            $result['ExposureMode'] = '!program!';
                            break;
                        case 2:
                            $result['ExposureMode'] = '!tv!';
                            break;
                        case 3:
                            $result['ExposureMode'] = '!av!';
                            break;
                        case 4:
                            $result['ExposureMode'] = '!manual!';
                            break;
                        case 5:
                            $result['ExposureMode'] = '!auto-dep!';
                            break;
                        default:
                            $result['ExposureMode'] = '!unknown!';
                    }
                    $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //21
                    $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //22
                    $result['LongFocalLength'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //23
                    $result['LongFocalLength'] .= " focal units";
                    $result['ShortFocalLength'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //24
                    $result['ShortFocalLength'] .= " focal units";
                    $result['FocalUnits'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //25
                    $result['FocalUnits'] .= " per mm";
                    $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //26
                    $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //27
                    $result['FlashActivity'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //28
                    switch ($result['FlashActivity']) {
                        case 0:
                            $result['FlashActivity'] = '!flash did not fire!';
                            break;
                        case 1:
                            $result['FlashActivity'] = '!flash fired!';
                            break;
                        default:
                            $result['FlashActivity'] = '!unknown!';
                    }
                    $result['FlashDetails'] = str_pad(base_convert(intel2Moto(substr($data, $place, 4)), 16, 2), 16, "0", STR_PAD_LEFT);
                    $place += 4;
                    //29
                    $flashDetails = array();
                    if (substr($result['FlashDetails'], 1, 1) == 1) {
                        $flashDetails[] = '!external e-ttl!';
                    }
                    if (substr($result['FlashDetails'], 2, 1) == 1) {
                        $flashDetails[] = '!internal flash!';
                    }
                    if (substr($result['FlashDetails'], 4, 1) == 1) {
                        $flashDetails[] = '!fp sync used!';
                    }
                    if (substr($result['FlashDetails'], 8, 1) == 1) {
                        $flashDetails[] = '!2nd(rear)-curtain sync used!';
                    }
                    if (substr($result['FlashDetails'], 12, 1) == 1) {
                        $flashDetails[] = '!1st curtain sync!';
                    }
                    $result['FlashDetails'] = implode(",", $flashDetails);
                    $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //30
                    $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //31
                    $anotherFocusMode = hexdec(intel2Moto(substr($data, $place, 4)));
                    $place += 4;
                    //32
                    if (strpos(strtoupper($exif['IFD0']['Model']), "G1") !== false) {
                        switch ($anotherFocusMode) {
                            case 0:
                                $result['FocusMode'] = '!single!';
                                break;
                            case 1:
                                $result['FocusMode'] = '!continuous!';
                                break;
                            default:
                                $result['FocusMode'] = '!unknown!';
                        }
                    }
                } else {
                    if ($tag == "0004") {
                        //second chunk
                        $result['Bytes'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //0
                        if ($result['Bytes'] != strlen($data) / 2) {
                            return $result;
                        }
                        //Bad chunk
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //1
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //2
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //3
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //4
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //5
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //6
                        $result['WhiteBalance'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //7
                        switch ($result['WhiteBalance']) {
                            case 0:
                                $result['WhiteBalance'] = '!auto!';
                                break;
                            case 1:
                                $result['WhiteBalance'] = '!sunny!';
                                break;
                            case 2:
                                $result['WhiteBalance'] = '!cloudy!';
                                break;
                            case 3:
                                $result['WhiteBalance'] = '!tungsten!';
                                break;
                            case 4:
                                $result['WhiteBalance'] = '!fluorescent!';
                                break;
                            case 5:
                                $result['WhiteBalance'] = '!flash!';
                                break;
                            case 6:
                                $result['WhiteBalance'] = '!custom!';
                                break;
                            default:
                                $result['WhiteBalance'] = '!unknown!';
                        }
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //8
                        $result['SequenceNumber'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //9
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //10
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //11
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //12
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //13
                        $result['AFPointUsed'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //14
                        $afPointUsed = array();
                        if ($result['AFPointUsed'] & 0x1) {
                            $afPointUsed[] = '!right!';
                        }
                        //bit 0
                        if ($result['AFPointUsed'] & 0x2) {
                            $afPointUsed[] = '!center!';
                        }
                        //bit 1
                        if ($result['AFPointUsed'] & 0x4) {
                            $afPointUsed[] = '!left!';
                        }
                        //bit 2
                        if ($result['AFPointUsed'] & 0x800) {
                            $afPointUsed[] = "12";
                        }
                        //bit 12
                        if ($result['AFPointUsed'] & 0x1000) {
                            $afPointUsed[] = "13";
                        }
                        //bit 13
                        if ($result['AFPointUsed'] & 0x2000) {
                            $afPointUsed[] = "14";
                        }
                        //bit 14
                        if ($result['AFPointUsed'] & 0x4000) {
                            $afPointUsed[] = "15";
                        }
                        //bit 15
                        $result['AFPointUsed'] = implode(",", $afPointUsed);
                        $result['FlashBias'] = intel2Moto(substr($data, $place, 4));
                        $place += 4;
                        //15
                        switch ($result['FlashBias']) {
                            case 'ffc0':
                                $result['FlashBias'] = "-2 EV";
                                break;
                            case 'ffcc':
                                $result['FlashBias'] = "-1.67 EV";
                                break;
                            case 'ffd0':
                                $result['FlashBias'] = "-1.5 EV";
                                break;
                            case 'ffd4':
                                $result['FlashBias'] = "-1.33 EV";
                                break;
                            case 'ffe0':
                                $result['FlashBias'] = "-1 EV";
                                break;
                            case 'ffec':
                                $result['FlashBias'] = "-0.67 EV";
                                break;
                            case 'fff0':
                                $result['FlashBias'] = "-0.5 EV";
                                break;
                            case 'fff4':
                                $result['FlashBias'] = "-0.33 EV";
                                break;
                            case '0000':
                                $result['FlashBias'] = "0 EV";
                                break;
                            case '000c':
                                $result['FlashBias'] = "0.33 EV";
                                break;
                            case '0010':
                                $result['FlashBias'] = "0.5 EV";
                                break;
                            case '0014':
                                $result['FlashBias'] = "0.67 EV";
                                break;
                            case '0020':
                                $result['FlashBias'] = "1 EV";
                                break;
                            case '002c':
                                $result['FlashBias'] = "1.33 EV";
                                break;
                            case '0030':
                                $result['FlashBias'] = "1.5 EV";
                                break;
                            case '0034':
                                $result['FlashBias'] = "1.67 EV";
                                break;
                            case '0040':
                                $result['FlashBias'] = "2 EV";
                                break;
                            default:
                                $result['FlashBias'] = '!unknown!';
                        }
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //16
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //17
                        $result['Unknown'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //18
                        $result['SubjectDistance'] = hexdec(intel2Moto(substr($data, $place, 4)));
                        $place += 4;
                        //19
                        $result['SubjectDistance'] .= "/100 m";
                    } else {
                        if ($tag == "0008") {
                            //image number
                            if ($intel == 1) {
                                $data = intel2Moto($data);
                            }
                            $data = hexdec($data);
                            $result = round($data / 10000) . "-" . $data % 10000;
                        } else {
                            if ($tag == "000c") {
                                //camera serial number
                                if ($intel == 1) {
                                    $data = intel2Moto($data);
                                }
                                $data = hexdec($data);
                                $result = "#" . bin2hex(substr($data, 0, 16)) . substr($data, 16, 16);
                            }
                        }
                    }
                }
            } else {
                if ($type == "UNDEFINED") {
                } else {
                    $data = bin2hex($data);
                    if ($intel == 1) {
                        $data = intel2Moto($data);
                    }
                }
            }
        }
    }
    return $data;
}
Example #11
0
function formatData($type, $tag, $intel, $data)
{
    switch ($type) {
        case 'ASCII':
            if (($pos = strpos($data, chr(0))) !== false) {
                // Search for a null byte and stop there.
                $data = substr($data, 0, $pos);
            }
            if ($tag == '010f') {
                $data = ucwords(strtolower(trim($data)));
            }
            // Format certain kinds of strings nicely (Camera make etc.)
            break;
        case 'URATIONAL':
        case 'SRATIONAL':
            switch ($tag) {
                case '011a':
                    // XResolution
                // XResolution
                case '011b':
                    // YResolution
                    $data = round(unRational($data, $type, $intel)) . ' dots per ResolutionUnit';
                    break;
                case '829a':
                    // Exposure Time
                    $data = formatExposure(unRational($data, $type, $intel));
                    break;
                case '829d':
                    // FNumber
                    $data = 'f/' . round(unRational($data, $type, $intel), 2);
                    break;
                case '9204':
                    // ExposureBiasValue (assume signed!)
                    $data = round(unRational($data, 'SRATIONAL', $intel), 2) . ' EV';
                    break;
                case '9205':
                    // ApertureValue
                // ApertureValue
                case '9202':
                    // MaxApertureValue
                    // ApertureValue is given in the APEX Mode. Many thanks to Matthieu Froment for this code
                    // The formula is : Aperture = 2*log2(FNumber) <=> FNumber = e((Aperture.ln(2))/2)
                    $datum = exp(unRational($data, $type, $intel) * log(2) / 2);
                    $data = 'f/' . round($datum, 1);
                    // Focal is given with a precision of 1 digit.
                    break;
                case '920a':
                    // FocalLength
                    $data = unRational($data, $type, $intel) . ' mm';
                    break;
                case '9201':
                    // ShutterSpeedValue
                    // The ShutterSpeedValue is given in the APEX mode. Many thanks to Matthieu Froment for this code
                    // The formula is : Shutter = - log2(exposureTime) (Appendix C of EXIF spec.)
                    // Where shutter is in APEX, log2(exposure) = ln(exposure)/ln(2)
                    // So final formula is : exposure = exp(-ln(2).shutter)
                    // The formula can be developed : exposure = 1/(exp(ln(2).shutter))
                    $datum = exp(unRational($data, $type, $intel) * log(2));
                    if ($datum != 0) {
                        $datum = 1 / $datum;
                    }
                    $data = formatExposure($datum);
                    break;
                default:
                    $data = unRational($data, $type, $intel);
                    break;
            }
            break;
        case 'USHORT':
        case 'SSHORT':
        case 'ULONG':
        case 'SLONG':
        case 'FLOAT':
        case 'DOUBLE':
            $data = rational($data, $type, $intel);
            switch ($tag) {
                case '0112':
                    // Orientation
                    // Example of how all of these tag formatters should be...
                    switch ($data) {
                        case 0:
                            // not set, presume normal
                        // not set, presume normal
                        case 1:
                            $data = '!1: normal (0 deg)!';
                            break;
                        case 2:
                            $data = '!2: mirrored!';
                            break;
                        case 3:
                            $data = '!3: upside-down!';
                            break;
                        case 4:
                            $data = '!4: upside-down mirrored!';
                            break;
                        case 5:
                            $data = '!5: 90 deg ccw mirrored!';
                            break;
                        case 6:
                            $data = '!6: 90 deg cw!';
                            break;
                        case 7:
                            $data = '!7: 90 deg cw mirrored!';
                            break;
                        case 8:
                            $data = '!8: 90 deg ccw!';
                            break;
                        default:
                            $data = sprintf('%d: ' . '!unknown!', $data);
                            break;
                    }
                    break;
                case '0128':
                    // ResolutionUnit
                // ResolutionUnit
                case 'a210':
                    // FocalPlaneResolutionUnit
                // FocalPlaneResolutionUnit
                case '0128':
                    // ThumbnailResolutionUnit
                    switch ($data) {
                        case 1:
                            $data = '!no unit!';
                            break;
                        case 2:
                            $data = '!inch!';
                            break;
                        case 3:
                            $data = '!centimeter!';
                            break;
                    }
                    break;
                case '0213':
                    // YCbCrPositioning
                    switch ($data) {
                        case 1:
                            $data = '!center of pixel array!';
                            break;
                        case 2:
                            $data = '!datum point!';
                            break;
                    }
                    break;
                case '8822':
                    // ExposureProgram
                    switch ($data) {
                        case 1:
                            $data = '!manual!';
                            break;
                        case 2:
                            $data = '!program!';
                            break;
                        case 3:
                            $data = '!aperture priority!';
                            break;
                        case 4:
                            $data = '!shutter priority!';
                            break;
                        case 5:
                            $data = '!program creative!';
                            break;
                        case 6:
                            $data = '!program action!';
                            break;
                        case 7:
                            $data = '!portrait!';
                            break;
                        case 8:
                            $data = '!landscape!';
                            break;
                        default:
                            $data = '!unknown!' . ': ' . $data;
                            break;
                    }
                    break;
                case '8830':
                    // SensitivityType
                    switch ($data) {
                        case 1:
                            $data = '!standard output sensitivity!';
                            break;
                        case 2:
                            $data = '!recommended exposure index!';
                            break;
                        case 3:
                            $data = '!iso speed!';
                            break;
                        case 4:
                            $data = '!standard output sensitivity and recommended exposure index!';
                            break;
                        case 5:
                            $data = '!standard output sensitivity and iso speed!';
                            break;
                        case 6:
                            $data = '!recommended exposure index and iso speed!';
                            break;
                        case 7:
                            $data = '!standard output sensitivity, recommended exposure index and iso speed!';
                            break;
                        default:
                            $data = '!unknown!' . ': ' . $data;
                            break;
                    }
                    break;
                case '9207':
                    // MeteringMode
                    switch ($data) {
                        case 1:
                            $data = '!average!';
                            break;
                        case 2:
                            $data = '!center weighted average!';
                            break;
                        case 3:
                            $data = '!spot!';
                            break;
                        case 4:
                            $data = '!multi-spot!';
                            break;
                        case 5:
                            $data = '!pattern!';
                            break;
                        case 6:
                            $data = '!partial!';
                            break;
                        case 255:
                            $data = '!other!';
                            break;
                        default:
                            $data = '!unknown!' . ': ' . $data;
                            break;
                    }
                    break;
                case '9208':
                    // LightSource
                    switch ($data) {
                        case 1:
                            $data = '!daylight!';
                            break;
                        case 2:
                            $data = '!fluorescent!';
                            break;
                        case 3:
                            $data = '!tungsten!';
                            break;
                            // 3 Tungsten (Incandescent light)
                            // 4 Flash
                            // 9 Fine Weather
                        // 3 Tungsten (Incandescent light)
                        // 4 Flash
                        // 9 Fine Weather
                        case 10:
                            $data = '!flash!';
                            break;
                            // 10 Cloudy Weather
                            // 11 Shade
                            // 12 Daylight Fluorescent (D 5700 - 7100K)
                            // 13 Day White Fluorescent (N 4600 - 5400K)
                            // 14 Cool White Fluorescent (W 3900 -4500K)
                            // 15 White Fluorescent (WW 3200 - 3700K)
                            // 10 Flash
                        // 10 Cloudy Weather
                        // 11 Shade
                        // 12 Daylight Fluorescent (D 5700 - 7100K)
                        // 13 Day White Fluorescent (N 4600 - 5400K)
                        // 14 Cool White Fluorescent (W 3900 -4500K)
                        // 15 White Fluorescent (WW 3200 - 3700K)
                        // 10 Flash
                        case 17:
                            $data = '!standard light a!';
                            break;
                        case 18:
                            $data = '!standard light b!';
                            break;
                        case 19:
                            $data = '!standard light c!';
                            break;
                        case 20:
                            $data = 'D55';
                            break;
                        case 21:
                            $data = 'D65';
                            break;
                        case 22:
                            $data = 'D75';
                            break;
                        case 23:
                            $data = 'D50';
                            break;
                        case 24:
                            $data = '!iso studio tungsten!';
                            break;
                        case 255:
                            $data = '!other!';
                            break;
                        default:
                            $data = '!unknown!' . ': ' . $data;
                            break;
                    }
                    break;
                case '9209':
                    // Flash
                    switch ($data) {
                        case 0:
                        case 16:
                        case 24:
                        case 32:
                        case 64:
                        case 80:
                            $data = '!no flash!';
                            break;
                        case 1:
                            $data = '!flash!';
                            break;
                        case 5:
                            $data = '!flash, strobe return light not detected!';
                            break;
                        case 7:
                            $data = '!flash, strobe return light detected!';
                            break;
                        case 9:
                            $data = '!compulsory flash!';
                            break;
                        case 13:
                            $data = '!compulsory flash, return light not detected!';
                            break;
                        case 15:
                            $data = '!compulsory flash, return light detected!';
                            break;
                        case 25:
                            $data = '!flash, auto-mode!';
                            break;
                        case 29:
                            $data = '!flash, auto-mode, return light not detected!';
                            break;
                        case 31:
                            $data = '!flash, auto-mode, return light detected!';
                            break;
                        case 65:
                            $data = '!red eye!';
                            break;
                        case 69:
                            $data = '!red eye, return light not detected!';
                            break;
                        case 71:
                            $data = '!red eye, return light detected!';
                            break;
                        case 73:
                            $data = '!red eye, compulsory flash!';
                            break;
                        case 77:
                            $data = '!red eye, compulsory flash, return light not detected!';
                            break;
                        case 79:
                            $data = '!red eye, compulsory flash, return light detected!';
                            break;
                        case 89:
                            $data = '!red eye, auto-mode!';
                            break;
                        case 93:
                            $data = '!red eye, auto-mode, return light not detected!';
                            break;
                        case 95:
                            $data = '!red eye, auto-mode, return light detected!';
                            break;
                        default:
                            $data = '!unknown!' . ': ' . $data;
                            break;
                    }
                    break;
                case 'a001':
                    // ColorSpace
                    if ($data == 1) {
                        $data = '!srgb!';
                    } else {
                        $data = '!uncalibrated!';
                    }
                    break;
                case 'a002':
                    // ExifImageWidth
                // ExifImageWidth
                case 'a003':
                    // ExifImageHeight
                    $data = $data . ' ' . '!pixels!';
                    break;
                case '0103':
                    // Compression
                    switch ($data) {
                        case 1:
                            $data = '!no compression!';
                            break;
                        case 6:
                            $data = '!jpeg compression!';
                            break;
                        default:
                            $data = '!unknown!' . ': ' . $data;
                            break;
                    }
                    break;
                case 'a217':
                    // SensingMethod
                    switch ($data) {
                        case 1:
                            $data = '!not defined!';
                            break;
                        case 2:
                            $data = '!one chip color area sensor!';
                            break;
                        case 3:
                            $data = '!two chip color area sensor!';
                            break;
                        case 4:
                            $data = '!three chip color area sensor!';
                            break;
                        case 5:
                            $data = '!color sequential area sensor!';
                            break;
                        case 7:
                            $data = '!trilinear sensor!';
                            break;
                        case 8:
                            $data = '!color sequential linear sensor!';
                            break;
                        default:
                            $data = '!unknown!' . ': ' . $data;
                            break;
                    }
                    break;
                case '0106':
                    // PhotometricInterpretation
                    switch ($data) {
                        case 1:
                            $data = '!monochrome!';
                            break;
                        case 2:
                            $data = '!rgb!';
                            break;
                        case 6:
                            $data = '!ycbcr!';
                            break;
                        default:
                            $data = '!unknown!' . ': ' . $data;
                            break;
                    }
                    break;
                    //case "a408":	// Contrast
                    //case "a40a":	//Sharpness
                    //	switch($data) {
                    //		case 0: $data="Normal"; break;
                    //		case 1: $data="Soft"; break;
                    //		case 2: $data="Hard"; break;
                    //		default: $data="Unknown"; break;
                    //	}
                    //	break;
                    //case "a409":	// Saturation
                    //	switch($data) {
                    //		case 0: $data="Normal"; break;
                    //		case 1: $data="Low saturation"; break;
                    //		case 2: $data="High saturation"; break;
                    //		default: $data="Unknown"; break;
                    //	}
                    //	break;
                    //case "a402":	// Exposure Mode
                    //	switch($data) {
                    //		case 0: $data="Auto exposure"; break;
                    //		case 1: $data="Manual exposure"; break;
                    //		case 2: $data="Auto bracket"; break;
                    //		default: $data="Unknown"; break;
                    //	}
                    //	break;
            }
            break;
        case 'UNDEFINED':
            switch ($tag) {
                case '9000':
                    // ExifVersion
                // ExifVersion
                case 'a000':
                    // FlashPixVersion
                // FlashPixVersion
                case '0002':
                    // InteroperabilityVersion
                    $data = '!version!' . ' ' . $data / 100;
                    break;
                case 'a300':
                    // FileSource
                    $data = bin2hex($data);
                    $data = str_replace('00', '', $data);
                    $data = str_replace('03', '!digital still camera!', $data);
                    break;
                case 'a301':
                    // SceneType
                    $data = bin2hex($data);
                    $data = str_replace('00', '', $data);
                    $data = str_replace('01', '!directly photographed!', $data);
                    break;
                case '9101':
                    // ComponentsConfiguration
                    $data = bin2hex($data);
                    $data = str_replace('01', 'Y', $data);
                    $data = str_replace('02', 'Cb', $data);
                    $data = str_replace('03', 'Cr', $data);
                    $data = str_replace('04', 'R', $data);
                    $data = str_replace('05', 'G', $data);
                    $data = str_replace('06', 'B', $data);
                    $data = str_replace('00', '', $data);
                    break;
                    //case "9286":	//UserComment
                    //	$encoding	= rtrim(substr($data, 0, 8));
                    //	$data		= rtrim(substr($data, 8));
                    //	break;
            }
            break;
        default:
            $data = bin2hex($data);
            if ($intel == 1) {
                $data = intel2Moto($data);
            }
            break;
    }
    return $data;
}
Example #12
0
function formatNikonData($type, $tag, $intel, $model, $data)
{
    switch ($type) {
        case "ASCII":
            break;
            // do nothing!
        // do nothing!
        case "URATIONAL":
        case "SRATIONAL":
            switch ($tag) {
                case '0084':
                    // LensInfo
                    $minFL = unRational(substr($data, 0, 8), $type, $intel);
                    $maxFL = unRational(substr($data, 8, 8), $type, $intel);
                    $minSP = unRational(substr($data, 16, 8), $type, $intel);
                    $maxSP = unRational(substr($data, 24, 8), $type, $intel);
                    if ($minFL == $maxFL) {
                        $data = sprintf('%0.0fmm f/%0.1f', $minFL, $minSP);
                    } elseif ($minSP == $maxSP) {
                        $data = sprintf('%0.0f-%0.0fmm f/%0.1f', $minFL, $maxFL, $minSP);
                    } else {
                        $data = sprintf('%0.0f-%0.0fmm f/%0.1f-%0.1f', $minFL, $maxFL, $minSP, $maxSP);
                    }
                    break;
                case "0085":
                    if ($model == 1) {
                        $data = unRational($data, $type, $intel) . " m";
                    }
                    //ManualFocusDistance
                    break;
                case "0086":
                    if ($model == 1) {
                        $data = unRational($data, $type, $intel) . "x";
                    }
                    //DigitalZoom
                    break;
                case "000a":
                    if ($model == 0) {
                        $data = unRational($data, $type, $intel) . "x";
                    }
                    //DigitalZoom
                    break;
                default:
                    $data = unRational($data, $type, $intel);
                    break;
            }
            break;
        case "USHORT":
        case $type == "SSHORT":
        case $type == "ULONG":
        case $type == "SLONG":
        case $type == "FLOAT":
        case $type == "DOUBLE":
            $data = rational($data, $type, $intel);
            switch ($tag) {
                case "0003":
                    if ($model == 0) {
                        //Quality
                        switch ($data) {
                            case 1:
                                $data = '!vga basic!';
                                break;
                            case 2:
                                $data = '!vga normal!';
                                break;
                            case 3:
                                $data = '!vga fine!';
                                break;
                            case 4:
                                $data = '!sxga basic!';
                                break;
                            case 5:
                                $data = '!sxga normal!';
                                break;
                            case 6:
                                $data = '!sxga fine!';
                                break;
                            default:
                                $data = '!unknown!' . ": " . $data;
                                break;
                        }
                    }
                    break;
                case "0004":
                    if ($model == 0) {
                        //Color
                        switch ($data) {
                            case 1:
                                $data = '!color!';
                                break;
                            case 2:
                                $data = '!monochrome!';
                                break;
                            default:
                                $data = '!unknown!' . ": " . $data;
                                break;
                        }
                    }
                    break;
                case "0005":
                    if ($model == 0) {
                        //Image Adjustment
                        switch ($data) {
                            case 0:
                                $data = '!normal!';
                                break;
                            case 1:
                                $data = '!bright+!';
                                break;
                            case 2:
                                $data = '!bright-!';
                                break;
                            case 3:
                                $data = '!contrast+!';
                                break;
                            case 4:
                                $data = '!contrast-!';
                                break;
                            default:
                                $data = '!unknown!' . ": " . $data;
                                break;
                        }
                    }
                    break;
                case "0006":
                    if ($model == 0) {
                        //CCD Sensitivity
                        switch ($data) {
                            case 0:
                                $data = "ISO-80";
                                break;
                            case 2:
                                $data = "ISO-160";
                                break;
                            case 4:
                                $data = "ISO-320";
                                break;
                            case 5:
                                $data = "ISO-100";
                                break;
                            default:
                                $data = '!unknown!' . ": " . $data;
                                break;
                        }
                    }
                    break;
                case "0007":
                    if ($model == 0) {
                        //White Balance
                        switch ($data) {
                            case 0:
                                $data = '!auto!';
                                break;
                            case 1:
                                $data = '!preset!';
                                break;
                            case 2:
                                $data = '!daylight!';
                                break;
                            case 3:
                                $data = '!incandescence!';
                                break;
                            case 4:
                                $data = '!fluorescence!';
                                break;
                            case 5:
                                $data = '!cloudy!';
                                break;
                            case 6:
                                $data = '!speedlight!';
                                break;
                            default:
                                $data = '!unknown!' . ": " . $data;
                                break;
                        }
                    }
                    break;
                case "000b":
                    if ($model == 0) {
                        //Converter
                        switch ($data) {
                            case 0:
                                $data = '!none!';
                                break;
                            case 1:
                                $data = '!fisheye!';
                                break;
                            default:
                                $data = '!unknown!' . ": " . $data;
                                break;
                        }
                    }
                    break;
            }
            break;
        case "UNDEFINED":
            switch ($tag) {
                case "0001":
                    if ($model == 1) {
                        $data = $data / 100;
                    }
                    break;
                    //Unknown (Version?)
                    break;
                case "0088":
                    if ($model == 1) {
                        //AF Focus Position
                        $temp = '!center!';
                        $data = bin2hex($data);
                        $data = str_replace("01", "Top", $data);
                        $data = str_replace("02", "Bottom", $data);
                        $data = str_replace("03", "Left", $data);
                        $data = str_replace("04", "Right", $data);
                        $data = str_replace("00", "", $data);
                        if (strlen($data) == 0) {
                            $data = $temp;
                        }
                    }
                    break;
            }
            break;
        default:
            $data = bin2hex($data);
            if ($intel == 1) {
                $data = intel2Moto($data);
            }
            switch ($tag) {
                case "0083":
                    if ($model == 1) {
                        //Lens Type
                        $data = hexdec(substr($data, 0, 2));
                        switch ($data) {
                            case 0:
                                $data = '!af non d!';
                                break;
                            case 1:
                                $data = '!manual!';
                                break;
                            case 2:
                                $data = "AF-D or AF-S";
                                break;
                            case 6:
                                $data = "AF-D G";
                                break;
                            case 10:
                                $data = "AF-D VR";
                                break;
                            case 14:
                                $data = "AF-D G VR";
                                break;
                            default:
                                $data = '!unknown!' . ": " . $data;
                                break;
                        }
                    }
                    break;
                case "0087":
                    if ($model == 1) {
                        //Flash type
                        $data = hexdec(substr($data, 0, 2));
                        if ($data == 0) {
                            $data = '!did not fire!';
                        } else {
                            if ($data == 4) {
                                $data = '!unknown!';
                            } else {
                                if ($data == 7) {
                                    $data = '!external!';
                                } else {
                                    if ($data == 9) {
                                        $data = '!on camera!';
                                    } else {
                                        $data = '!unknown!' . ": " . $data;
                                    }
                                }
                            }
                        }
                    }
                    break;
            }
            break;
    }
    return $data;
}
Example #13
0
function formatPanasonicData($type, $tag, $intel, $data)
{
    if ($type == "ASCII") {
    } else {
        if ($type == "UBYTE" || $type == "SBYTE") {
            $data = bin2hex($data);
            if ($intel == 1) {
                $data = intel2Moto($data);
            }
            $data = hexdec($data);
            if ($tag == "000f") {
                //AFMode
                if ($data == 256) {
                    $data = "9-area-focusing";
                } else {
                    if ($data == 16) {
                        $data = "1-area-focusing";
                    } else {
                        if ($data == 4096) {
                            $data = '!3-area-focusing (high speed)!';
                        } else {
                            if ($data == 4112) {
                                $data = '!1-area-focusing (high speed)!';
                            } else {
                                if ($data == 16) {
                                    $data = '!1-area-focusing!';
                                } else {
                                    if ($data == 1) {
                                        $data = '!spot-focusing!';
                                    } else {
                                        $data = '!unknown!' . " (" . $data . ")";
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } else {
            if ($type == "URATIONAL" || $type == "SRATIONAL") {
                $data = unRational($data, $type, $intel);
            } else {
                if ($type == "USHORT" || $type == "SSHORT" || $type == "ULONG" || $type == "SLONG" || $type == "FLOAT" || $type == "DOUBLE") {
                    $data = rational($data, $type, $intel);
                    if ($tag == "0001") {
                        //Image Quality
                        if ($data == 2) {
                            $data = '!high!';
                        } else {
                            if ($data == 3) {
                                $data = '!standard!';
                            } else {
                                if ($data == 6) {
                                    $data = '!very high!';
                                } else {
                                    if ($data == 7) {
                                        $data = '!raw!';
                                    } else {
                                        $data = '!unknown!' . " (" . $data . ")";
                                    }
                                }
                            }
                        }
                    }
                    if ($tag == "0003") {
                        //White Balance
                        if ($data == 1) {
                            $data = '!auto!';
                        } else {
                            if ($data == 2) {
                                $data = '!daylight!';
                            } else {
                                if ($data == 3) {
                                    $data = '!cloudy!';
                                } else {
                                    if ($data == 4) {
                                        $data = '!halogen!';
                                    } else {
                                        if ($data == 5) {
                                            $data = '!manual!';
                                        } else {
                                            if ($data == 8) {
                                                $data = '!flash!';
                                            } else {
                                                if ($data == 10) {
                                                    $data = '!black and white!';
                                                } else {
                                                    if ($data == 11) {
                                                        $data = '!manual!';
                                                    } else {
                                                        $data = '!unknown!' . " (" . $data . ")";
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ($tag == "0007") {
                        //Focus Mode
                        if ($data == 1) {
                            $data = '!auto!';
                        } else {
                            if ($data == 2) {
                                $data = '!manual!';
                            } else {
                                if ($data == 4) {
                                    $data = '!auto, focus button!';
                                } else {
                                    if ($data == 5) {
                                        $data = '!auto, continuous!';
                                    } else {
                                        $data = '!unknown!' . " (" . $data . ")";
                                    }
                                }
                            }
                        }
                    }
                    if ($tag == "001a") {
                        //Image Stabilizer
                        if ($data == 2) {
                            $data = '!mode 1!';
                        } else {
                            if ($data == 3) {
                                $data = '!off!';
                            } else {
                                if ($data == 4) {
                                    $data = '!mode 2!';
                                } else {
                                    $data = '!unknown!' . " (" . $data . ")";
                                }
                            }
                        }
                    }
                    if ($tag == "001c") {
                        //Macro mode
                        if ($data == 1) {
                            $data = '!on!';
                        } else {
                            if ($data == 2) {
                                $data = '!off!';
                            } else {
                                $data = '!unknown!' . " (" . $data . ")";
                            }
                        }
                    }
                    if ($tag == "001f") {
                        //Shooting Mode
                        if ($data == 1) {
                            $data = '!normal!';
                        } else {
                            if ($data == 2) {
                                $data = '!portrait!';
                            } else {
                                if ($data == 3) {
                                    $data = '!scenery!';
                                } else {
                                    if ($data == 4) {
                                        $data = '!sports!';
                                    } else {
                                        if ($data == 5) {
                                            $data = '!night portrait!';
                                        } else {
                                            if ($data == 6) {
                                                $data = '!program!';
                                            } else {
                                                if ($data == 7) {
                                                    $data = '!aperture priority!';
                                                } else {
                                                    if ($data == 8) {
                                                        $data = '!shutter priority!';
                                                    } else {
                                                        if ($data == 9) {
                                                            $data = '!macro!';
                                                        } else {
                                                            if ($data == 11) {
                                                                $data = '!manual!';
                                                            } else {
                                                                if ($data == 13) {
                                                                    $data = '!panning!';
                                                                } else {
                                                                    if ($data == 14) {
                                                                        $data = '!simple!';
                                                                    } else {
                                                                        if ($data == 18) {
                                                                            $data = '!fireworks!';
                                                                        } else {
                                                                            if ($data == 19) {
                                                                                $data = '!party!';
                                                                            } else {
                                                                                if ($data == 20) {
                                                                                    $data = '!snow!';
                                                                                } else {
                                                                                    if ($data == 21) {
                                                                                        $data = '!night scenery!';
                                                                                    } else {
                                                                                        if ($data == 22) {
                                                                                            $data = '!food!';
                                                                                        } else {
                                                                                            if ($data == 23) {
                                                                                                $data = '!baby!';
                                                                                            } else {
                                                                                                if ($data == 27) {
                                                                                                    $data = '!high sensitivity!';
                                                                                                } else {
                                                                                                    if ($data == 29) {
                                                                                                        $data = '!underwater!';
                                                                                                    } else {
                                                                                                        if ($data == 33) {
                                                                                                            $data = '!pet!';
                                                                                                        } else {
                                                                                                            $data = '!unknown!' . " (" . $data . ")";
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ($tag == "0020") {
                        //Audio
                        if ($data == 1) {
                            $data = '!yes!';
                        } else {
                            if ($data == 2) {
                                $data = '!no!';
                            } else {
                                $data = '!unknown!' . " (" . $data . ")";
                            }
                        }
                    }
                    if ($tag == "0023") {
                        //White Balance Bias
                        $data = $data . " EV";
                    }
                    if ($tag == "0024") {
                        //Flash Bias
                        $data = $data;
                    }
                    if ($tag == "0028") {
                        //Colour Effect
                        if ($data == 1) {
                            $data = '!off!';
                        } else {
                            if ($data == 2) {
                                $data = '!warm!';
                            } else {
                                if ($data == 3) {
                                    $data = '!cool!';
                                } else {
                                    if ($data == 4) {
                                        $data = '!black and white!';
                                    } else {
                                        if ($data == 5) {
                                            $data = '!sepia!';
                                        } else {
                                            $data = '!unknown!' . " (" . $data . ")";
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ($tag == "002a") {
                        //Burst Mode
                        if ($data == 0) {
                            $data = '!off!';
                        } else {
                            if ($data == 1) {
                                $data = '!low/high quality!';
                            } else {
                                if ($data == 2) {
                                    $data = '!infinite!';
                                } else {
                                    $data = '!unknown!' . " (" . $data . ")";
                                }
                            }
                        }
                    }
                    if ($tag == "002c") {
                        //Contrast
                        if ($data == 0) {
                            $data = '!standard!';
                        } else {
                            if ($data == 1) {
                                $data = '!low!';
                            } else {
                                if ($data == 2) {
                                    $data = '!high!';
                                } else {
                                    $data = '!unknown!' . " (" . $data . ")";
                                }
                            }
                        }
                    }
                    if ($tag == "002d") {
                        //Noise Reduction
                        if ($data == 0) {
                            $data = '!standard!';
                        } else {
                            if ($data == 1) {
                                $data = '!low!';
                            } else {
                                if ($data == 2) {
                                    $data = '!high!';
                                } else {
                                    $data = '!unknown!' . " (" . $data . ")";
                                }
                            }
                        }
                    }
                    if ($tag == "002e") {
                        //Self Timer
                        if ($data == 1) {
                            $data = '!off!';
                        } else {
                            if ($data == 2) {
                                $data = '10 ' . '!sec!';
                            } else {
                                if ($data == 3) {
                                    $data = '2 ' . '!sec!';
                                } else {
                                    $data = '!unknown!' . " (" . $data . ")";
                                }
                            }
                        }
                    }
                    if ($tag == "0030") {
                        //Rotation
                        if ($data == 1) {
                            $data = '!horizontal (normal)!';
                        } else {
                            if ($data == 6) {
                                $data = '!rotate 90 cw!';
                            } else {
                                if ($data == 8) {
                                    $data = '!rotate 270 cw!';
                                } else {
                                    $data = '!unknown!' . " (" . $data . ")";
                                }
                            }
                        }
                    }
                    if ($tag == "0032") {
                        //Color Mode
                        if ($data == 0) {
                            $data = '!normal!';
                        } else {
                            if ($data == 1) {
                                $data = '!natural!';
                            } else {
                                $data = '!unknown!' . " (" . $data . ")";
                            }
                        }
                    }
                    if ($tag == "0036") {
                        //Travel Day
                        $data = $data;
                    }
                } else {
                    if ($type == "UNDEFINED") {
                    } else {
                        $data = bin2hex($data);
                        if ($intel == 1) {
                            $data = intel2Moto($data);
                        }
                    }
                }
            }
        }
    }
    return $data;
}