exif data
HejJeg har et problem med at løse exif data fra et billede. Dvs jeg har faktisk testet det virker når jeg taster linket yil billedet ind men ikek hvis jeg vil bruge den string som generers når jeg uploader billedet. Kan I hjælpe mig?
Kode:
$mappe = $_POST[mappe];
$structure = 'billeder/kontrol/';
$slut = '/';
$nymappe = $structure . $mappe . $slut;
if ($_POST['referer'] == 'post_news') {
if ($_FILES['image']['name'] != '') {
$image = time().substr($_FILES['image']['name'],strrpos($_FILES['image']['name'],'.'));
move_uploaded_file($_FILES['image']['tmp_name'], $nymappe . $image);
// OKmove_uploaded_file($_FILES['image']['tmp_name'], 'billeder/kontrol/'.$image);
// move_uploaded_file($_FILES['image']['tmp_name'], '../billeder/projekter/'.$image);
$uploadimage1 = $nymappe . $image;
$imagePath ='.' . $uploadimage1;
//$imagePath ='http://www.kjell-p.dk/billeder/kontrol/Kvindehjemmet/DSC_0842.JPG';
// This function is used to determine the camera details for a specific image. It returns an array with the parameters.
function cameraUsed($imagePath) {
// Check if the variable is set and if the file itself exists before continuing
if ((isset($imagePath)) and (file_exists($imagePath))) {
// There are 2 arrays which contains the information we are after, so it's easier to state them both
$exif_ifd0 = read_exif_data($imagePath ,'IFD0' ,0);
$exif_exif = read_exif_data($imagePath ,'EXIF' ,0);
//error control
$notFound = "Unavailable";
// Make
if (@array_key_exists('Make', $exif_ifd0)) {
$camMake = $exif_ifd0['Make'];
} else { $camMake = $notFound; }
// Model
if (@array_key_exists('Model', $exif_ifd0)) {
$camModel = $exif_ifd0['Model'];
} else { $camModel = $notFound; }
// Exposure
if (@array_key_exists('ExposureTime', $exif_ifd0)) {
$camExposure = $exif_ifd0['ExposureTime'];
} else { $camExposure = $notFound; }
// Aperture
if (@array_key_exists('ApertureFNumber', $exif_ifd0['COMPUTED'])) {
$camAperture = $exif_ifd0['COMPUTED']['ApertureFNumber'];
} else { $camAperture = $notFound; }
// Date
if (@array_key_exists('DateTime', $exif_ifd0)) {
$camDate = $exif_ifd0['DateTime'];
} else { $camDate = $notFound; }
// Oreintation
if (@array_key_exists('Orientation', $exif_ifd0)) {
$camOrien = $exif_ifd0['Orientation'];
} else { $camOrien = $notFound; }
// ISO
if (@array_key_exists('ISOSpeedRatings',$exif_exif)) {
$camIso = $exif_exif['ISOSpeedRatings'];
} else { $camIso = $notFound; }
$return = array();
$return['make'] = $camMake;
$return['model'] = $camModel;
$return['exposure'] = $camExposure;
$return['aperture'] = $camAperture;
$return['date'] = $camDate;
$return['orientation'] = $camOrien;
$return['iso'] = $camIso;
return $return;
} else {
return false;
}
}
//echo 'NIKO';
//echo $imagePath;
//echo '<br>';
//echo $camera;
//echo '<br>SLUT<br>';
$imagePath2 ='".' . $uploadimage1 . '"';
echo 'imagepath2: ';
echo $imagePath2;
echo '<br>imagepath: ';
echo $imagePath;
///////FEJLEN ER HER ////////////
$camera = 'cameraUsed('.$imagePath2.')';
echo $camera;
//////////////////////////////
// HVIS JEG DEFINERER $camera som nedenfor virker scriptet, men //jeg vil gerne have den selv til at vælge billedet så jeg kan
//uploade forskellige billeder
//// MED STIEN SKREVET MANUELT VIRKER SCRIPTET///////
//$camera = cameraUsed("./billeder/kontrol/Kvindehjemmet/IMG_6209.JPG");
//echo "Camera Used: " . $camera['make'] . " " . $camera['model'] . "<br />";
//echo "Exposure Time: " . $camera['exposure'] . "<br />";
//echo "Aperture: " . $camera['aperture'] . "<br />";
//echo "ISO: " . $camera['iso'] . "<br />";
//echo "Date Taken: " . $camera['date'] . "<br />";
$billeddato = $camera['date'];
$orientering = $camera['orientation'];
//echo "Orientation " . $camera['orientation'] . "<br />";