Zum Inhalt springen

EXIF-Daten bei goof_fotoboek

Erstellt am 21. Januar 2007 · 3 Antworten · letzte Antwort am 22. Januar 2007

Tags: Bilder, PHP, Frage

wolfi02 ·

Hallo Leute,

ich mir Extension goof_fotoboek installiert und soweit läuft auch alles. Die Funktionen zum EXIF-Daten auslesen bei den Bildern find ich sehr. Nur möchte ich nicht alle möglichen Daten eines Bildes erhalten, sondern nur bestimmte, z.B. Copyright, Beschreibung, Autor, etc.

In der Datei class.tx_gooffotoboek_pi1.php habe ich (denke ich mal) die Funktionen gefunden, die dafür verantwortlich sind.

/**
		* Get EXIF information if possible
		* method priority is metacam, jhead and PHP internal EXIF support
		*
		* @param string  $file: path to the original image
		* @return string  Exif information in html format
		*/
		function getExif($file) {
		  $exif = $this->getExifArray($file);
		  if ( count( $exif ) == 0 ) {
		    $ret .= 'NO EXIF Information metacam or jhead not configured and no exif support in this php version<br />';
		  }
		  else {
		    $exiftable = '';
		    $exif_fields = '/Image Capture Date|Make$|Model|ISO Speed Rating|Image Description|' 
				.'Focal Length|Flash$|Aperture|Exposure Time|Shutter Speed Value|' 
				.'Date\/?Time$|ISO equiv|Flash used/i';
		    foreach ($exif as $key => $value) {
		      if (preg_match($exif_fields , $key) or $this->conf['show_exif_all'] == 1) {
			if ($value) {
			  $exiftable .= $this->fastWrap($key,$this->conf['exif_tag_wrap'])
			    .$this->fastWrap($value,$this->conf['exif_value_wrap']);
			}
		      }
		    }
		    if ($exiftable != '') {
		      $ret .=$this->fastWrap($exiftable,$this->conf['exif_all_wrap']);
		    }
		  }
		  return $ret;
		}



		 
		/**
		* Get EXIF information if possible
		* method priority is metacam, jhead and PHP internal EXIF support
		*
		* @param string  $file: path to the original image
		* @return string  Exif information in html format
		*/
		function getExifnot($file) {
			$ret = '';
			// for older php version an external program is needed
			// I chose metacam and jhead to get the
			if (@file_exists($this->conf['exif_metacam'])) {
				exec('"'.$this->conf['exif_metacam'].'" "'.$file.'"' , $txt);
				if (is_array($txt)) {
					foreach ($txt as $row) {
						preg_match('/^([^:]+):(.*)$/', $row, $match);
						$exif[ $match[1] ] = $match[2];
					}
				}
			} elseif (@file_exists($this->conf['exif_jhead'])) {
				exec('"'.$this->conf['exif_jhead'].'" "'.$file.'"' , $txt);
				if (is_array($txt)) {
					foreach ($txt as $row) {
						preg_match('/^([^:]+):(.*)$/', $row, $match);
						$exif[ $match[1] ] = $match[2];
					}
				}
			} elseif (@function_exists(exif_read_data)) {
				$txt = exif_read_data($file, 'EXIF', false);
				if (is_array($txt)) {
					foreach ($txt as $name => $val) {
						$val = preg_replace('/[^\w\d\s=\/:]/' , '', $val);
						$exif[$name] = $val;
					}
				}
			} else {
				$ret .= 'NO EXIF Information metacam or jhead not configured and no exif support in this php version<br />';
			}
			if (is_array($exif)) {
				$exiftable = '';
				// time patch by Sven
				$exif_fields = '/Image Capture Date|Make$|Model|ISO Speed Rating|Image Description|' .'Focal Length|Flash$|Aperture|Exposure Time|Shutter Speed Value|' .'Date\/?Time$|ISO equiv|Flash used/i';
				foreach ($exif as $key => $value) {
					if (preg_match($exif_fields , $key) or $this->conf['show_exif_all'] == 1) {
						if ($value) {
							$exiftable .= $this->fastWrap($key, $this->conf['exif_tag_wrap'])
							.$this->fastWrap($value, $this->conf['exif_value_wrap']);
						}
					}
				}
				if ($exiftable != '') {
					$ret .= $this->fastWrap($exiftable, $this->conf['exif_all_wrap']);
				}
			}
			return $ret;
		}

Nur hab ich leider keine Ahnung, wie ich die Funktionen nun anpassen muss, um nicht alle EXIF-Daten zu erhalten.
Kann da jemand weiterhelfen?

mfg
Christian

steffenk ·
$exif_fields = '/Image Capture Date|Make$|Model|ISO Speed Rating|Image Description|' 
                                .'Focal Length|Flash$|Aperture|Exposure Time|Shutter Speed Value|' 
                                .'Date\/?Time$|ISO equiv|Flash used/i';

Da steht doch drin wonach gesucht wird.

wolfi02 ·

Hallo steffenk,

danke für die Antwort, habe die entsprechenden Stellen inzwischen auch gefunden. Nun habe ich aber das Problem, das bei der Ausgabe der EXIF-Daten, keine Umlaute ausgegeben werden. Parsen wird in sofern schwierig, da alle Umlaute das gleiche Symbol bekommen (Â).
Ich weiß, dieser Bereich des Forums ist dafür nicht gedacht, aber wie kann ich da jetzt eine XML-Datei mit einbinden, die mir z.B. die Headerinformationen ins deutsche Übersetzt (Ausgabe lautet: Image Description, soll aber Bildbeschreibung heißen)?

mfg
Christian

steffenk ·

tja, schau Dir meine Ext sk_simplegallery an, da binde ich auch exif ein und geb es korrekt aus ...

ich hab da eine php-lib eingebunden und bekomme ein Array zurück. Da kann man sich aussuchen welche man anzeigenm will.

fotoboek hatte die auch mal drin ...