4images Modifications / Modifikationen > Mods & Plugins (Releases & Support)

[Mod] EXIF V1.7.10 Optional Googlemap

(1/15) > >>

Rembrandt:
Hi!

Codeupdate: step 8.) 10.) 16.02.2013

Für V1.7.10 oder höher.

Dieser MOD erweitert die in der Version 1.7.10 enthaltene EXIF funktion um folgendes:

Alle EXIF Daten der Bilder, werden ausgelesen und in die Datenbank geschrieben.
Dadurch können Bilder nach EXIF Daten gesucht werden.

Optional 1: wenn in den Bilder Geo Koordinaten vorhanden sind können diese in einer Google Map (inkl. Wetterdaten) dagestellt werden.
Optional 2: Member Google Map Addon, EXIF Daten werden auch in die Datenbank geschrieben, wenn die Bilder über das Member Uploadformular hoch geladen werden.  
            Member können mittels einer Google Map den Bilder Geo Koordinaten hinzufügen.

Zu Modifizierenden Dateien:
 1.) SQL Table "wordmatch","images" und "images_temp" erstellen.
       (im Anhang befindet sich die install_iptc.php um die benötigten Datenbankfelder automatisch anzulegen.)
 2.) admin/checkimages.php
 3.) includes/db_field_definitions.php
 4.) includes/functions.php
 5.) root/config.php
 6.) lang/your lang/main.php
 7.) EXIF Daten der Bilder in die Datenbank schreiben.

1.) speichert die datei "install_exif.php" aus dem anhang in euren root ab, und ruft sie auf.

2.) suche in der admin/checkimage.php:

$sql = "INSERT INTO ".IMAGES_TABLE."

füge  darüber ein:

//############################### Start Exif ############################################
  $src_file = ($big_file) ? MEDIA_PATH."/".$cat_id."/".$big_folder."/".$big_file : $file;
  $size = getimagesize ($src_file, $info);
    if(function_exists('exif_read_data') && $exif_data = @exif_read_data($src_file, 'EXIF')) {
          $exif_array = get_exif_info($exif_data);
      foreach ($exif_array as $key => $val) {
        $additional_field_sql .= ',image_'.$key;
        $additional_value_sql .= ",'".$val."'";
      }
    }
//############################### End Exif #############################################

2.1) suche:

add_searchwords($image_id, $search_words);

füge darunter ein:

//################################## Start Exif IPTC  #########################
          $sql = "SELECT image_id".$additional_field_sql."
                  FROM ".IMAGES_TABLE."
                  WHERE image_id = $image_id
                  ";
          $result = $site_db->query($sql);
          while ($row = $site_db->fetch_array($result)) {
            $additional_search_words = array();
            foreach ($search_match_fields as $image_column => $match_column) {
              if (isset($row[$image_column])) {
                $additional_search_words[$image_column] = $row[$image_column];
              }
            }
            add_searchwords($image_id, $additional_search_words);
          };
//################################## End Exif IPTC ##########################


3.) suche in der includes/db_field_definition.php

?>

füge darüber ein:

//################################ Start Exif ##################################################
$additional_image_fields['image_Make'] = array($lang['exif_Make'], "text", 0);
$additional_image_fields['image_Model'] = array($lang['exif_Model'], "text", 0);
$additional_image_fields['image_DateTimeOriginal'] = array($lang['exif_DateTimeOriginal'], "text", 0);
$additional_image_fields['image_ISOSpeedRatings'] = array($lang['exif_ISOSpeedRatings'], "text", 0);
$additional_image_fields['image_ExposureTime'] = array($lang['exif_ExposureTime'], "text", 0);
$additional_image_fields['image_FNumber'] = array($lang['exif_FNumber'], "text", 0);
$additional_image_fields['image_FocalLength'] = array($lang['exif_FocalLength'], "text", 0);
$additional_image_fields['image_ExposureBiasValue'] = array($lang['exif_ExposureBiasValue'], "text", 0);
$additional_image_fields['image_ApertureValue'] = array($lang['exif_ApertureValue'], "text", 0);
$additional_image_fields['image_MaxApertureValue'] = array($lang['exif_MaxApertureValue'], "text", 0);
$additional_image_fields['image_MeteringMode'] = array($lang['exif_MeteringMode'], "text", 0);
$additional_image_fields['image_Flash'] = array($lang['exif_Flash'], "text", 0);
$additional_image_fields['image_ExposureProgram'] = array($lang['exif_ExposureProgram'], "text", 0);
$additional_image_fields['image_ExposureMode'] = array($lang['exif_ExposureMode'], "text", 0);
$additional_image_fields['image_WhiteBalance'] = array($lang['exif_WhiteBalance'], "text", 0);
$additional_image_fields['image_GPSLatitudeRef'] = array($lang['exif_GPSLatitudeRef'], "text", 0);
$additional_image_fields['image_GPSLatitude'] = array($lang['exif_GPSLatitude'], "text", 0);
$additional_image_fields['image_GPSLongitudeRef'] = array($lang['exif_GPSLongitudeRef'], "text", 0);
$additional_image_fields['image_GPSLongitude'] = array($lang['exif_GPSLongitude'], "text", 0);
$additional_image_fields['image_GPSAltitude'] = array($lang['exif_GPSAltitude'], "text", 0);
$additional_image_fields['image_GPSTrack'] = array($lang['exif_GPSTrack'], "text", 0);
//################################ End Exif #################################################


4.) suche in der includes/functions.php:

function get_exif_info($exif) {
  $exif_match = array();
  $exif_match['Make'] = "make";
  $exif_match['Model'] = "model";
  $exif_match['DateTimeOriginal'] = "datetime";
  $exif_match['ISOSpeedRatings'] = "isospeed";
  $exif_match['ExposureTime'] = "exposure";
  $exif_match['FNumber'] = "aperture";
  $exif_match['FocalLength'] = "focallen";

  $exif_array = array();
  if (is_array($exif)) {
    foreach ($exif as $key => $val) {
      if (isset($exif_match[$key])) {
        $exif_info = $val;
        if ($key == "DateTimeOriginal") {
          $exif_array[$exif_match[$key]] = preg_replace("/([0-9]{4}):([0-9]{2}):([0-9]{2})/", "\\3.\\2.\\1", $exif_info);
        }
        elseif ($key == "ExposureTime") {
          $ExposureTime = explode("/", $exif_info);
          if ((float)$ExposureTime[1] == 0) {
            $exif_array[$exif_match[$key]] = "0 sec(s)";
          }
          elseif (($ExposureTime[0]/$ExposureTime[1]) >= 0.3) {
            $exif_array[$exif_match[$key]] = round(($ExposureTime[0]/$ExposureTime[1]),1)." sec(s)";
          }
          else {
            $exif_array[$exif_match[$key]] = "1/".round((1/($ExposureTime[0]/$ExposureTime[1])),0)." sec(s)";
          }
        }
        elseif ($key == "FNumber") {
  $aperture = explode("/", $exif_info);
          $exif_array[$exif_match[$key]] = "F/" . ($aperture[0] / $aperture[1]);
        }
        elseif ($key == "FocalLength") {
  $focalLen = explode("/", $exif_info);
          $exif_array[$exif_match[$key]] = ($focalLen[0] / $focalLen[1]) . "mm";
        }
        else {
          $exif_array[$exif_match[$key]] = $exif_info;
        }
      }
    }
  }
  return $exif_array;
}

und ersetze es mit:

function get_exif_info($exif) {
$exif_match = array();
  $exif_match['Make'] = "Make";
  $exif_match['Model'] = "Model";
  $exif_match['DateTimeOriginal'] = "DateTimeOriginal";
  $exif_match['ISOSpeedRatings'] = "ISOSpeedRatings";
  $exif_match['ExposureTime'] = "ExposureTime";
  $exif_match['FNumber'] = "FNumber";
  $exif_match['FocalLength'] = "FocalLength";
  $exif_match['ExposureBiasValue'] = "ExposureBiasValue";
  $exif_match['ApertureValue'] = "ApertureValue";
  $exif_match['MaxApertureValue'] = "MaxApertureValue";
  $exif_match['MeteringMode'] = "MeteringMode";
  $exif_match['Flash'] = "Flash";
  $exif_match['ExposureProgram'] = "ExposureProgram";
  $exif_match['ExposureMode'] = "ExposureMode";
  $exif_match['WhiteBalance'] = "WhiteBalance";
  $exif_match['GPSLatitude'] = "GPSLatitude";
  $exif_match['GPSLatitudeRef'] = "GPSLatitudeRef";
  $exif_match['GPSLongitude'] = "GPSLongitude";
  $exif_match['GPSLongitudeRef'] = "GPSLongitudeRef";
  $exif_match['GPSAltitude'] = "GPSAltitude";
  $exif_match['GPSTrack'] = "GPSTrack";

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


4.1) suche:

        if ($detailed_view && $image_info[2] == 2 && function_exists('exif_read_data') && $exif_data = @exif_read_data($src, 'EXIF')) {
          $exif_array = get_exif_info($exif_data);
          $bgcounter = 0;
          foreach ($exif_array as $key => $val) {
            $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
            $site_template->register_vars(array(
           
              "exif_value" => format_text($val),
              "exif_name" => $lang['exif_'.$key],
              "row_bg_number" => $row_bg_number
            ));
            $exif_info .= $site_template->parse_template("exif_bit");
          }
        }

ersetze es mit:

//############################ Start EXIF ##############################
        if ($detailed_view ) {
          global $site_db,$lang,$additional_image_fields;
          $additional_field_sql = "";
          foreach ($additional_image_fields as $key => $val){
            $additional_field_sql .= ','.$key;
          }
          $sql = "SELECT image_id".$additional_field_sql."
                  FROM ".IMAGES_TABLE."
                  WHERE image_id = '$image_id'";
          $result = $site_db->query($sql);
          $row = mysql_fetch_object($result);
          $GPSLongitude = $row->image_GPSLongitude;
          $GPSLatitude = $row->image_GPSLatitude;          
          $bgcounter = 0;
          foreach ($row as $key => $val) {
            if ($val != "") {
              $search_key = $key;
              $url_val = '"' . $val . '"';
              $val = (is_numeric($val)) ? round($val,6) : $val;
              $key = str_replace('image_','',($key));
             
              if (isset($lang['exif_'.$key])) {
                $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
                
                $site_template->register_vars(array(
                  "exif_value" => "<a href=\"".$site_sess->url(ROOT_PATH."search.php?search_keywords=".urlencode($url_val))."&amp;search_fields=$search_key \">".format_text($val)."</a>",
                  "exif_name" => $lang['exif_'.$key],
                  "row_bg_number" => $row_bg_number,
                  "image_lat" => $GPSLatitude,
                  "image_lon" => $GPSLongitude
                ));
                $exif_info .= $site_template->parse_template("exif_bit");
              }
            }
          }
        }
//########################### End Exif ###################################


5.) suche in der root/config.php:

?>

füge davor ein:

$search_index_types = array(
  "image_id" =>  "phrase",
  "image_Make" => "phrase",
  "image_Model" => "phrase",
  "image_DateTimeOriginal" => "phrase",
  "image_ISOSpeedRatings" => "phrase",
  "image_ExposureTime" => "phrase",
  "image_FNumber" => "phrase",
  "image_FocalLength" => "phrase",
  "image_ExposureBiasValue" => "phrase",
  "image_ApertureValue" => "phrase",
  "image_MaxApertureValue" => "phrase",
  "image_MeteringMode" => "phrase",
  "image_Flash" => "phrase",
  "image_ExposureProgram" => "phrase",
  "image_ExposureMode" => "phrase",
  "image_WhiteBalance" => "phrase",
  "image_GPSLatitude" => "phrase",
  "image_GPSLatitudeRef" => "phrase",
  "image_GPSLongitude" => "phrase",
  "image_GPSLongitudeRef" => "phrase",
  "image_GPSAltitude" => "phrase",
  "image_GPSTrack" => "phrase",
  );
$search_match_fields = array(
    "image_name" => "name_match",
    "image_description" => "desc_match",
    "image_keywords" => "keys_match",
    "image_Make" => "Make_match",
    "image_Model" => "Model_match",
    "image_DateTimeOriginal" => "DateTimeOriginal_match",
    "image_ISOSpeedRatings" => "ISOSpeedRatings_match",
    "image_ExposureTime" => "ExposureTime_match",
    "image_FNumber" => "FNumber_match",
    "image_FocalLength" => "FocalLength_match",
    "image_ExposureBiasValue" => "ExposureBiasValue_match",
    "image_ApertureValue" => "ApertureValue_match",
    "image_MaxApertureValue" => "MaxApertureValue_match",
    "image_MeteringMode" => "MeteringMode_match",
    "image_Flash" => "Flash_match",
    "image_ExposureProgram" => "ExposureProgram_match",
    "image_ExposureMode" => "ExposureMode_match",
    "image_WhiteBalance" => "WhiteBalance_match",
    "image_GPSLatitude" => "GPSLatitude_match",
    "image_GPSLatitudeRef" => "GPSLatitudeRef_match",
    "image_GPSLongitude" => "GPSLongitude_match",
    "image_GPSLongitudeRef" => "GPSLongitudeRef_match",
    "image_GPSAltitude" => "GPSAltitude_match",
    "image_GPSTrack" => "GPSTrack_match",
); 


6.) suche in lang/your lang/main.php:
(english)

$lang['exif_make'] = "Make:";
$lang['exif_model'] = "Model:";
$lang['exif_datetime'] = "Date created:";
$lang['exif_isospeed'] = "ISO speed:";
$lang['exif_exposure'] = "Exposure time:";
$lang['exif_aperture'] = "Aperture value:";
$lang['exif_focallen'] = "Focal length:";

and replace:

$lang['exif_Make'] = "Make:";
$lang['exif_Model'] = "Modell:";
$lang['exif_DateTimeOriginal'] = "Exposure,Date and Time:";
$lang['exif_ISOSpeedRatings'] = "ISO Speed Rating:";
$lang['exif_ExposureTime'] = "Exposure Time:";
$lang['exif_FNumber'] = "Aperture:";
$lang['exif_FocalLength'] = "Focal Length (Object Lens):";
$lang['exif_ExposureBiasValue'] = "Exposure Bias Value:";
$lang['exif_ApertureValue'] = "Aperture Value:";
$lang['exif_MaxApertureValue'] = "Max Aperture Value:";
$lang['exif_MeteringMode'] = "Metering Mode:";
$lang['exif_Flash'] = "Flash:";
$lang['exif_ExposureProgram'] = "Exposure Program:";
$lang['exif_ExposureMode'] = "Exposure Mode:";
$lang['exif_WhiteBalance'] = "Whitebalance:";
$lang['exif_GPSLatitudeRef'] = "GPS Latitude Referenz:";
$lang['exif_GPSLatitude'] = "GPS Latitude:";
$lang['exif_GPSLongitudeRef'] = "GPS Longitude Referenz";
$lang['exif_GPSLongitude'] = "GPS Longitude:";
$lang['exif_GPSAltitude'] = "GPS Altitude:";
$lang['exif_GPSTrack'] = "GPS Track:";

suche:
(deutsch)

$lang['exif_make'] = "Hersteller:";
$lang['exif_model'] = "Modell:";
$lang['exif_datetime'] = "Aufnahmedatum:";
$lang['exif_isospeed'] = "ISO-Zahl:";
$lang['exif_exposure'] = "Belichtungszeit:";
$lang['exif_aperture'] = "Blende:";
$lang['exif_focallen'] = "Brennweite:"

und ersetze es mit:    

$lang['exif_Make'] = "Hersteller:";
$lang['exif_Model'] = "Modell:";
$lang['exif_DateTimeOriginal'] = "Aufnahme,Datum und Zeit:";
$lang['exif_ISOSpeedRatings'] = "ISO Wert:";
$lang['exif_ExposureTime'] = "Belichtungszeit:";
$lang['exif_FNumber'] = "Blende:";
$lang['exif_FocalLength'] = "Brennweite (Objektiv):";
$lang['exif_ExposureBiasValue'] = "Belichtungsabweichung:";
$lang['exif_ApertureValue'] = "Blendenöffnungswert:";
$lang['exif_MaxApertureValue'] = "Maximaler Blendenöffnungswert:";
$lang['exif_MeteringMode'] = "Belichtungsmessung:";
$lang['exif_Flash'] = "Blitz:";
$lang['exif_ExposureProgram'] = "Belichtungsprogramm:";
$lang['exif_ExposureMode'] = "Belichtungsmodus:";
$lang['exif_WhiteBalance'] = "Weißabgleich:";
$lang['exif_GPSLatitudeRef'] = "GPS Breitengrad Referenz:";
$lang['exif_GPSLatitude'] = "GPS Breitengrad:";
$lang['exif_GPSLongitudeRef'] = "GPS Längengrad Referenz:";
$lang['exif_GPSLongitude'] = "GPS Längengrad:";
$lang['exif_GPSAltitude'] = "GPS Höhe:";
$lang['exif_GPSTrack'] = "GPS Blickrichtung:";


7.) Kopiert die Datei "create_exif_data.php" (im Anhang) nach admin/plugins und führ sie 1x aus.
    Mit dieser Datei werden die schon vorhanden Bilder der Galerie nach EXIF Daten durchsucht und in die Datenbank geschrieben.
    Falls ihr schon EXIF Daten in der Datenbank habt braucht ihr diesen schritt nicht durchführen.
 
 
OPTION 1: wenn in den Bilder Geo Koordinaten vorhanden sind können diese in einer Google Map dagestellt werden.

8.) erstellt in euren root einen neuen ordner mit den namen "js" und speichert die datei "googlemap.js"(im anhang) darin ab.
  
9.) suche in schritt 4.):

      }
    }
    $site_template->register_vars(array(
      "media_src" => $media_src,

füge darüber ein:

//############################ Start Google Map #################################
      $google_map ="";
      $google_info ="";      
      if ((!empty($GPSLongitude)) && (!empty($GPSLatitude))){ 
        $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;

        $google_info = "
           &nbsp;<a href = 'http://maps.google.de/maps?q=$GPSLatitude,$GPSLongitude&amp;t=h&amp;ie=UTF8&amp;ll=$GPSLatitude,$GPSLongitude&amp;spn=0.002316,0.005021&amp;z=18&amp;om=1' onclick=\"void(window.open(this.href, '', '')); return false;\">Position in Google Karte öffnen</a>
          <br>
          &nbsp;<a href = 'http://maps.live.com/default.aspx?v=2&amp;cp=$GPSLatitude~$GPSLongitude&amp;style=h&amp;lvl=17&amp;tilt=-90&amp;dir=0&amp;alt=-1000&amp;scene=6176719&amp;encType=1' onclick=\"void(window.open(this.href, '', '')); return false;\">Position in Microsoft Live Karte öffnen</a>
          <br>
          &nbsp;<a href = 'http://www.flashearth.com/?lat=$GPSLatitude&amp;lon=$GPSLongitude&amp;z=15.8&amp;r=0&amp;src=ggl' onclick=\"void(window.open(this.href, '', '')); return false;\">Position in Flash Earth öffnen</a><br>
         ";

        $google_map = "
          <script type='text/javascript' src='./js/googlemap.js'></script>
            <script type='text/javascript'>
              GPSLatitude = '$GPSLatitude';
              GPSLongitude = '$GPSLongitude';
              imagename = '$image_name';
            </script>
         ";
     }
           $site_template->register_vars(array(
        "google_map" => $google_map,
        "google_info" => $google_info
      ));
  //############################ End Google Map ##########################


10.) suche in deinen template/details.html:

--- Code: ---{endif exif_info}

--- End code ---
füge darunter ein:

--- Code: ---                  {if google_map}
                    <br>
                    <table width="100%" border="0" cellspacing="0" cellpadding="1">
                      <tr>
                        <td class="bordercolor">
                          <table width="100%" border="0" cellpadding="3" cellspacing="0">
                            <tr>
                            <td class="head1" valign="top"colspan="2">Google Info: &nbsp;</td>
                            </tr>
                          </table>
                          <table  width="100%"  border="0" class="row1"cellpadding="3" cellspacing="0">
                            <tr>  
                              <td valign="top" cellpadding="3" width="260px" class="row1">
                              {google_info}
                              </td>
                              <td class="google">
                                <div id="map_canvas" style="float:left;width:500px;height:300px;margin:10px 0px;"></div>
                                {google_map}
                              </td>
                            </tr>
                          </table>
                        </td>
                      </tr>
                    </table>
                  {endif google_map}

--- End code ---

mfg Andi

66

Rembrandt:
Code Update: step 2.1) 3.); 16.02.2013

EXIF Daten werden auch in die Datenbank geschrieben, wenn die Bilder über das Member Uploadformular hoch geladen werden.  
 Member können mittels einer Google Map den Bilder Geo Koordinaten hinzufügen.
 
1.) suche in der member.php im abschnitt($action == "updateimage"):

$image_keywords = implode(',', array_unique(array_filter($image_keywords_arr)));

füge darunter ein:

//####################### Start Googlemap ############################ 
  $image_GPSLatitude = intval($HTTP_POST_VARS['image_GPSLatitude']);
  $image_GPSLongitude = intval($HTTP_POST_VARS['image_GPSLongitude']);
//####################### End Googlemap ############################## 

1.1) suche in der member.php im abschnitt($action == "updateimage"):

$additional_sql .= ", $key = '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'"

füge darüber ein:

//########################## Start Google map ##########################################      
          if($HTTP_POST_VARS['image_GPSLatitude'] != 0 && $HTTP_POST_VARS['image_GPSLongitude'] != 0){
            if($key == 'image_GPSLatitude'){
              if($HTTP_POST_VARS['image_GPSLatitude']< 0 ){
                $additional_sql .= ", image_GPSLatitudeRef = 'Süd'";
              }else{
                $additional_sql .= ", image_GPSLatitudeRef = 'Nord'";
              }
              $additional_sql .= ", $key = '".(round(un_htmlspecialchars(trim($HTTP_POST_VARS[$key])),4))."'";
            }
              elseif($key == 'image_GPSLongitude'){
                if($HTTP_POST_VARS['image_GPSLongitude'] < 0 ){
                  $additional_sql .= ", image_GPSLongitudeRef = 'West'";
                }else{
                  $additional_sql .= ", image_GPSLongitudeRef = 'Ost'"; 
                }            
                $additional_sql .= ", $key = '".(round(un_htmlspecialchars(trim($HTTP_POST_VARS[$key])),4))."'"; 
              }  
              }else{
                $additional_sql .= ", image_GPSLatitudeRef = ''";
                $additional_sql .= ", image_GPSLongitudeRef = ''"; 
              }
//########################## End Google map #############################################


1.2) suche in der member.php im abschnitt($action == "editimage"):

  $txt_clickstream = get_category_path($image_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id)."\" 

füge darüber ein:

//######################### IPTC EXIF #########################################  
  foreach ($image_row as $key => $val) {
    if ($val && (!is_numeric($key))) {
    $hidden_fields .= "<input type=\"hidden\" name=\"$key\" value=\"$val\" />\n";
    }
  }
//######################### IPTC EXIF #########################################

1.3) suche:

  $site_template->register_vars(array(
    "image_id" => $image_id,
    "image_name" => format_text($image_name, 2),

ersetze es mit:

//################# Start Google map ##############################################################################
  $image_GPSLatitude = (isset($HTTP_POST_VARS['image_GPSLatitude'])) ? intval($HTTP_POST_VARS['image_GPSLatitude']) : ((($image_row['image_GPSLatitude'])) ? $image_row['image_GPSLatitude'] :"''");
  $image_GPSLongitude = (isset($HTTP_POST_VARS['image_GPSLongitude'])) ? intval($HTTP_POST_VARS['image_GPSLongitude']) : ((($image_row['image_GPSLongitude'])) ? $image_row['image_GPSLongitude'] :"''");
  
  $google_map = "
    <script type='text/javascript' src='./js/googlemap.js'></script>
    <script type='text/javascript'>
      var GPSLatitude = $image_GPSLatitude;
      var GPSLongitude = $image_GPSLongitude;
      var latlng = '1';
    </script>
  ";
//################# End Google map #################################################                
  $site_template->register_vars(array(
    "hidden_fields" => $hidden_fields, //########## IPTC EXIF ######################
    "google_map" => $google_map, //################# Google map ####################
    "image_id" => $image_id,
    "image_name" => format_text($image_name, 2),

1.4) suche:

    if (!$uploaderror) {
      $additional_field_sql = "";
      $additional_value_sql = "";
      if (!empty($additional_image_fields)) {
        $table = ($direct_upload) ? IMAGES_TABLE : IMAGES_TEMP_TABLE;
        $table_fields = $site_db->get_table_fields($table);
        foreach ($additional_image_fields as $key => $val) {
          if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
            $additional_field_sql .= ", $key";
            $additional_value_sql .= ", '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
          }
        }
      }

ersetze es mit:

    if (!$uploaderror) {
 if(!empty($additional_image_fields)) {
          //$additional_field_sql = ""; // bei exif auskommentieren
      //$additional_value_sql = ""; // bei exif auskommentieren 
//############################### Start Exif ############################################
      //$src_file = ($big_file) ? MEDIA_PATH."/".$cat_id."/".$big_folder."/".$big_file : $file;
      $src_file = $src;
      $size = getimagesize ($src_file, $info);
        if(function_exists('exif_read_data') && $exif_data = @exif_read_data($src_file, 'EXIF')) {
          $exif_array = get_exif_info($exif_data);
          foreach ($exif_array as $key => $val) {
            $additional_field_sql .= ',image_'.$key;
            $additional_value_sql .= ",'".$val."'";
          }
        }       
          if(isset($exif_array['GPSLatitude'])){
            unset($additional_image_fields['image_GPSLatitude']); 
            unset($additional_image_fields['image_GPSLongitude']); 
          }
        $table = ($direct_upload) ? IMAGES_TABLE : IMAGES_TEMP_TABLE;
        $table_fields = $site_db->get_table_fields($table);
        foreach ($additional_image_fields as $key => $val) {
          if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) { 
            if(($key == 'image_GPSLatitude') && !empty($HTTP_POST_VARS['image_GPSLatitude'])){
              if($HTTP_POST_VARS['image_GPSLatitude'] < 0 ){
                $additional_field_sql .= ", image_GPSLatitudeRef";
                $additional_value_sql .= ", 'Süd'";
              }else{
                $additional_field_sql .= ", image_GPSLatitudeRef";
                $additional_value_sql .= ", 'Nord'";
              }
              $additional_field_sql .= ", $key";
              $additional_value_sql .= ", '".(round(un_htmlspecialchars(trim($HTTP_POST_VARS[$key])),4))."'";
            }
            elseif(($key == 'image_GPSLongitude') && !empty($HTTP_POST_VARS['image_GPSLongitude'])){
              if($HTTP_POST_VARS['image_GPSLongitude'] < 0 ){
                $additional_field_sql .= ", image_GPSLongitudeRef";
                $additional_value_sql .= ", 'West'";
              }else{
                $additional_field_sql .= ", image_GPSLongitudeRef";
                $additional_value_sql .= ", 'Ost'";
              }            
              $additional_field_sql .= ", $key";
              $additional_value_sql .= ", '".(round(un_htmlspecialchars(trim($HTTP_POST_VARS[$key])),4))."'";
            } 
            else{ // Google map
              $additional_field_sql .= ", $key";
              $additional_value_sql .= ", '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
            } // Google map
          }  
        }
      }

1.5)suche:

          }
          add_searchwords($image_id, $search_words);

füge darunter ein:

//######################### Start Exif IPTC  #########################
          $sql = "SELECT image_id".$additional_field_sql."
                  FROM ".IMAGES_TABLE."
                  WHERE image_id = $image_id
                  ";
          $result = $site_db->query($sql);
          while ($row = $site_db->fetch_array($result)) {
            $additional_search_words = array();
            foreach ($search_match_fields as $image_column => $match_column) {
              if (isset($row[$image_column])) {
                $additional_search_words[$image_column] = $row[$image_column];
              }
            }
            add_searchwords($image_id, $additional_search_words);
          };
//####################### End Exif IPTC #########################

1.6)suche:

  $site_template->register_vars(array(
    "cat_id" => $cat_id,
    "cat_name" => ($cat_id != 0) ? format_text($cat_cache[$cat_id]['cat_name'],

ersetze es mit:

//################# Start Google map #####################################################  
  $google_map = "
    <script type='text/javascript' src='./js/googlemap.js'></script>
    <script type='text/javascript'>
      var latlng = '1';
    </script>
  "; 
//################# End Google map ##################################################### 
  $site_template->register_vars(array(
    "google_map" => $google_map, //googlemap
    "cat_id" => $cat_id,
    "cat_name" => ($cat_id != 0) ? format_text($cat_cache[$cat_id]['cat_name'], 2) : get_category_dropdown($cat_id),


2.) suche in deinen template/member_editimage.html:

--- Code: ---<form method="post" action="{url_member}" onsubmit="uploadbutton.disabled=true;">

--- End code ---
füge darunter ein:

--- Code: ---{hidden_fields}

--- End code ---
2.1) suche:

--- Code: ---              <textarea name="image_keywords" cols="30" rows="10" wrap="virtual" class="textarea">{image_keywords}</textarea>
            </td>
          </tr>

--- End code ---

füge darunter ein:

--- Code: ---          <tr>
            <td class="row1"><b>{lang_image_GPSLatitude}</b></td>
            <td class="row1"><input type="text" name="image_GPSLatitude"  id="lat" size="30" value="{image_GPSLatitude}" class="input" /></td>
          </tr>          
          <tr>
            <td class="row2"><b>{lang_image_GPSLongitude}</b></td>
            <td class="row2"><input type="text" name="image_GPSLongitude"  id="lng" size="30" value="{image_GPSLongitude}" class="input" /></td>
          </tr>
          <tr>
            <td class="row1"valign="top"><b>Map:</b></td>
            <td class="row1"> <div id="map_canvas" style="width: 450px; height: 300px"></div>
            {google_map}
            </td>
          </tr>

--- End code ---


3.) suche in deinen template/member_uploadform.html:

--- Code: ---              <textarea cols="30" class="textarea" rows="10" name="image_keywords">{image_keywords}</textarea>
            </td>
          </tr>

--- End code ---

füge darunter ein:

--- Code: ---          <tr>
            <td class="row1"><b>{lang_image_GPSLatitude}</b></td>
            <td class="row1"><input type="text" name="image_GPSLatitude"  id="lat" size="30" value="{image_GPSLatitude}" class="input" /></td>
          </tr>          
          <tr>
            <td class="row2"><b>{lang_image_GPSLongitude}</b></td>
            <td class="row2"><input type="text" name="image_GPSLongitude"  id="lng" size="30" value="{image_GPSLongitude}" class="input" /></td>
          </tr>
          <tr>
            <td class="row1"valign="top"><b>Map:</b></td>
            <td class="row1">
            <div id="map_canvas" style="width: 450px; height: 300px"></div>
            {google_map}
            </td>
          </tr>

--- End code ---


mfg Andi

mmarschner:
Hallo Andi,

ich bin gerade dabei, die MOD umzusetzen. Leider bekomme ich schon wieder Fehler, die augenscheinlich in der config.php liegen.

Wenn ich den Code eintrage, dann bekomme ich wieder den Fehler

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/motoly.de/httpdocs/gallerie/config.php:1)

Mit der Original config.php tritt der Fehler nicht auf. Ich habe die Dateien mit dem Windows Notepad editiert. Da sollten die Dateien sicherlich im Ascii-Format gespeichert werden.

Welches Programm benutzt Du, um den Code zu erstellen, bzw. in die vorhandenen Prozeduren einzufügen?

Dann ist anscheinend in der main.php (englisch) ebenfalls ein Fehler vorhanden. In Zeile 15 steht

$lang['exif_WhiteBalance'] = "Whitebalance:";";

Ich glaube das die letzten Anführungszeichen und das Semikoln da nicht hingehören. Wenn die eingefügt sind, öffnet sich die Seite nicht mehr, wenn ich die rausnehme wird die Seite wieder angezeigt.

Fragende Grüße von der Ostsee - zumindest für diese Wochenende wünscht

Michael

Rembrandt:

--- Quote from: mmarschner on May 14, 2011, 08:05:23 PM ---...
Ich glaube das die letzten Anführungszeichen und das Semikoln da nicht hingehören. ...
--- End quote ---
wo du recht hast du recht :)

zum code erstellen/editieren und auch hochladen (alles in einem) verwende ich notepad++

EDIT: wenn du ganze files hochladest sollte filezila sicher funktionieren, aber du siehst ja selber das die modifikationen an sich nichts dafür können,
erst wenn du eine datei bearbeitest und sie wieder hochladest kommen die fehler.

mmarschner:
Hallo Andi,

danke für die Info. Aber nach dem Erstellen der Exif Daten kommt in der Galerie im Header folgende Meldung ?

An unexpected error occured. Please try again later.

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/motoly.de/httpdocs/gallerie/includes/db_mysql.php on line 116

Es werden in der Galerie auch keine Bilder mehr angezeigt.


Nach der Erstellen der Exif Daten ist jedoch folgende Meldung gekommen:

Volltext-Indizierung zwischen ID 0 und 3:
Processing image Die Teilnehmermotorräder, ID 2... ... EXIF UPDATE
Processing image Der böse Blick, ID 3... ... EXIF UPDATE


EXIF Daten erstellt!

[Zurück]  

Michael


Anscheinend habe ich den Fehler gefunden. Es fehlte in der Datenbank ein Feld - image_LensType in der Tabelle images. Habe das Feld angelegt, und es klappt. Was mich interessieren würde, ist, ob das Feld auch in den anderen Tabellen zugefügt werden muss.

Michael

Navigation

[0] Message Index

[#] Next page

Go to full version