Index: /extensions/MoreExif_EOS300D-40D/picture_metadata.inc.php
===================================================================
--- /extensions/MoreExif_EOS300D-40D/picture_metadata.inc.php	(revision 4667)
+++ /extensions/MoreExif_EOS300D-40D/picture_metadata.inc.php	(revision 4667)
@@ -0,0 +1,635 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008      Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+/**
+ * This file is included by the picture page to manage picture metadata
+ *
+  Release 2.0.1 fix translation with common.lang.php definition
+  Release 2.0.2   manage 50D
+  Release 2.0.3/4 default 35mm focal length calculation for most common cameras / DSLR
+  All cameras will take benefit from this file, but the Canon at most. 
+  If you have a non Canon body and would like to see the MakerNotes, follow the metadata information, e.g. from 
+  http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/ and enhance this file!
+ */
+include_once(PHPWG_ROOT_PATH.'/include/functions_metadata.inc.php');
+if (($conf['show_exif']) and (function_exists('read_exif_data')))
+{
+  if ($exif = @read_exif_data($picture['current']['image_path']))
+  {
+    $exif = trigger_event('format_exif_data', $exif, $picture['current'] );
+ 
+    $tpl_meta = array(
+        'TITLE' => 'EXIF Metadata',
+        'lines' => array(),
+      );
+
+    // register make and model
+    if (in_array('Make', $exif))    
+	{ $make = trim($exif['Make']); }
+    else 
+    	{ $make = 'n/a'; }
+    if (in_array('Model', $exif)) 
+	{ $model = trim($exif['Model']); }
+    else 
+     	{ $model ='n/a'; }
+   	
+    foreach ($conf['show_exif_fields'] as $field)
+    {
+      if (strpos($field, ';') === false)
+      {  /*  ===> gbo modification  */
+	if (isset($exif[$field])) 
+	{
+	   // Look for Canon EOS camera
+	   if ($field == 'ModeArray') // Canon CameraSettings tags
+	   {
+		if ($make === 'Canon') // for Canon EOS and PowerShot/Ixus
+   		{ improve_meta_canon($exif[$field]); }
+	   }
+	   else
+	   {		
+		$key = $field; 
+		Conversion($key, $exif[$field], $model, $make);
+        	if (isset($lang['exif_field_'.$field]))
+		{
+			$key = $lang['exif_field_'.$field];
+		}		 
+	   }
+        // $tpl_meta['lines'][$key] = $exif[$field];
+	}
+      }
+      else
+      {
+ 	$tokens = explode(';', $field);
+        if (isset($exif[$tokens[0]][$tokens[1]]))
+        {
+           $key = $tokens[1];
+           if (isset($lang['exif_field_'.$tokens[1]]))
+           {
+              $key = $lang['exif_field_'.$tokens[1]];
+           }
+           $tpl_meta['lines'][$key] = $exif[$tokens[0]][$tokens[1]];
+        }
+      }
+    }
+    $template->append('metadata', $tpl_meta);
+  }
+}
+
+if ($conf['show_iptc'])
+{
+  $iptc = get_iptc_data($picture['current']['image_path'],
+                        $conf['show_iptc_mapping']);
+
+  if (count($iptc) > 0)
+  {
+    $tpl_meta = array(
+        'TITLE' => 'IPTC Metadata',
+        'lines' => array(),
+      );
+
+    foreach ($iptc as $field => $value)
+    {
+      $key = $field;
+      if (isset($lang[$field]))
+      {
+        $key = $lang[$field];
+      }
+      $tpl_meta['lines'][$key] = $value;
+    }
+    $template->append('metadata', $tpl_meta);
+  }
+}
+
+
+
+function Conversion($key, $data, $model, $make)
+{ 
+	global $tpl_meta, $lang;
+	// simplify make
+	$makeLow = strtolower($make); $makeR = $make;
+	if (strpos($makeLow, 'olympus') === 0 )
+	{	$makeR = 'Olympus'; }
+	else if (strpos($makeLow, 'nikon') === 0 )
+	{	$makeR = 'Nikon'; }
+	else if (strpos($makeLow, 'pentax') === 0 )
+	{ 	$makeR = 'Pentax'; }
+	else if (strpos($makeLow, 'sony') === 0 )
+	{ 
+		$makeR = 'Sony'; 
+	}
+
+	// proceed and rename key to have user readable english name. The lang file should transalate these new keys.
+	if ($key==='Model')
+	{ 	// merge make and model if model does not already contain make
+		//if ($make <> 'Canon' && $makeR <> 'Pentax') 
+		if (strpos( strtolower($model),  strtolower($makeR)) === false )
+		{   $data = $makeR.' '.$data; }		
+	}
+	if ($key==='ExposureBiasValue')  
+	{	
+		$key = 'ExposureCompensation';
+		$data = compute_fraction($data) ;
+		$data = round($data,2);
+		if ($data>0) {$data='+'.$data;} 
+		if ($data == 0) { $data = ""; }
+		else { $data.=' EV'; }
+	}		
+	if ($key==='ExposureTime') 
+	{
+		$key = 'ExposureTime';
+		$data = compute_fraction($data) ;
+		if ($data<1)	
+		{
+			$data=1/$data;
+			$data="1/".$data ; 
+		}
+		$data.="s";
+	}   
+	if ($key==='ShutterSpeedValue')
+	{
+		$key = 'ShutterSpeed';
+	}
+	if ($key=='FNumber') 
+	{	
+		$key = 'Aperture';
+		$data = compute_fraction($data) ;
+		$data = 'f/'. $data;
+	}
+	if ($key=="MaxApertureValue") 
+	{ 	
+		$key = 'MaxAperture';
+		$data = compute_fraction($data) ;
+		$data = round($data,1);
+		$data = 'f/'. $data;
+	}
+   	if ($key==='FocalLength')
+	{	
+		$key = 'FocalLength';
+		$data = compute_fraction($data) ;
+		$data .='mm';	
+		// first look for 35mm eq in meta, else make the calculation
+		if (isset($exif['FocalLengthIn35mmFilm'])) 
+		{
+			$f35 = compute_fraction($exif['FocalLengthIn35mmFilm']) ;
+		} 
+		else 
+		{
+			$cropFactor = CalculateCropFactor($model, $makeR);
+			if ($cropFactor > 1)
+			{ $f35 = $data*$cropFactor; }
+		}
+		if (isset($f35)) 
+		{
+			$data.=' (equiv 24x36: '.round($f35,0).'mm)';
+		}
+	}
+
+
+       	if ($key==='Flash')
+	{ 
+		if ($make === 'Canon') 
+		{ // disable it for Canon, as maker notes will be used
+			$data="";
+		}
+		else
+		{  // it seems that most camera are using a even value for "not fired" and an odd value for "fired"
+			if ($data%2 == 0)
+			{  $data=""; } //did not fire
+			else
+			{  $data="on"; } // 1 on olympus camera, 9 or 25 on panasonic
+		}
+	}
+	if ($key==='UndefinedTag:0x0095' and $make === 'Canon')
+	{
+		$key = 'LensName';
+	}
+	if ($key==='ISOSpeedRatings')
+	{
+		$key = 'ISO';
+	}
+	if ($key==='DateTimeOriginal')
+	{
+		$key = 'TakenDate';
+	}	
+	if ($data!="" ) 
+	{
+		if (isset($lang['exif_field_'.$key]))
+        	  { $key = $lang['exif_field_'.$key]; }
+        	$tpl_meta['lines'][$key] = $data;
+    	}
+}
+
+function compute_fraction($data)
+{ 
+	$tokens = explode('/', $data);
+	if (count($tokens)!=2) return $data ;
+	if ( $tokens[1] == 0 ) return $data ;
+	return floatval($tokens[0]) / floatval($tokens[1]) ;
+}
+
+// Calculate the crop factor of the camera which will be used for the 35mm focal length equivalence
+function CalculateCropFactor($model, $make)
+{
+	// set the crop factor
+	$cropFactor = 6; // average crop factor for compact cameras, for 1/2.5" sensor
+	if (strpos($model, 'Canon EOS') !== false) // only Canon EOS cameras
+	{
+		if (strpos($model, '0') > 0) // all APS-C models have a 0 in their name (Dx0, x0D, xx0D, x000D)
+		{ $cropFactor = 1.6; }
+        	else if (strpos($model, '1D ') > 0)  //1D body
+		{ $cropFactor = 1.3; }
+		else { $cropFactor = 1; }  //1Ds and 5D body
+	}
+	else if ($make === 'Nikon' && strpos($model, 'D') !== false ) // all Nikon DSLR start with "D"
+	{
+		if (strpos($model, 'D3') !== false || strpos($model, 'D700') !== false)
+		{ 	$cropFactor = 1; }
+		else {  $cropFactor = 1.5; }
+	}
+	else if ($make === 'Sony'  && strpos($model, 'DSLR-A') !== false) // DSLR Alpha
+	{
+		if (strpos($model, 'A900') !== false)
+		{ 	$cropFactor = 1; }
+		else {  $cropFactor = 1.5; }
+	}
+	else if ($make === 'Pentax' && strpos($model, 'K') !== false ) // all Pentax DSLR start with "K"
+	{	$cropFactor = 1.5;  }
+	else if ($make === 'Olympus') // all Olympus DSLR start with "E"
+	{
+	 	if  (strpos($model, 'E') === 0)
+		{
+		    if (strpos($model, 'E-10') !== false || strpos($model, 'E-20') !== false)
+		    {   $cropFactor = 3.88;  }   // sensor size: 8.8x6.6, 2/3"
+		    else 
+		    {   $cropFactor = 2;  }   // sensor size: 18x13.5mm
+		}
+		else if ($model === 'C2040Z') // Eric's old compact camera
+		{   	$cropFactor = 5.48;  } // sensor size: 1/2"
+	}
+
+	return $cropFactor;
+}
+
+function improve_meta_canon($subarray)
+{
+  global $tpl_meta, $lang, $model;
+  $isEOS = strpos($model, 'Canon EOS') !== false ;
+  if (is_array ($subarray) )
+  {
+	$maxLen = '';  // will be set for the minLen and displayed together
+	foreach ($subarray as $Elem => $subval)
+	{
+		$data= ""; 
+		$key ="";
+		switch ($Elem) 
+		{	
+		    case 1: // added
+		    	$key="Macro Mode";
+			switch($subval) 
+			{
+				case 1: $data="Macro"; break;
+				//case 2: $data="Normal"; break; // do not display if set
+			}
+			break;
+		    case 2:
+			if ($subval  > 0)
+			{
+				$key="SelfTimer";
+				$data.=$subval/10; 
+			  	$data=$data.' s';
+			}
+			break;		
+		    case 3:
+			$key="ImageQuality";
+			switch($subval) 
+			{
+				case 2: $data.="Normal"; break;
+				case 3: $data.="Fine"; break;
+				case 4: $data.="Raw"; break;
+				case 5: $data.="Superfine"; break;
+			     // default : $data.' ?';
+			}
+			break;							 
+		    case 4:
+			$key="Flash Mode";
+			switch($subval) 
+			{
+			  	case 0: $data.=''; break; //Off
+				case 1: $data.="Auto"; break;
+				case 2: $data.="On"; break;
+				case 3: $data.="Red Eye Reduction"; break;
+				case 4: $data.="Slow Synchro"; break;
+				case 5: $data.="Auto + Red Eye Reduction"; break;
+				case 6: $data.="On + Red Eye Reduction"; break;
+			        case 16: $data.="External" ; break;
+			}
+			break;							 
+		    case 5:
+			$key="Drive";
+			switch($subval) 
+			{
+				case 0: $data.="Single"; break;
+				case 1: $data.="Continus"; break;
+				case 2: $data.="Movie"; break;
+				case 3: $data.="Continuous, Speed Priority"; break;
+				case 4: $data.="Continus Low"; break;
+				case 5: $data.="Continus High"; break;
+				default : $data.=$subval.' ?';
+			}
+			break; 							 
+		    case 7: 
+			$key="FocusMode";
+			switch($subval) 
+			{
+				case 0: $data.='One-shot AF'; break;
+				case 1: $data.='AI Servo AF'; break;
+				case 2: $data.='AI Focus AF'; break;
+				case 3: $data.='Manual Focus'; break;
+				case 4: $data.='Single'; break;
+				case 5: $data.='Continuous'; break;
+				case 6: $data.='Manual Focus'; break;
+				default: $data.='Autre ('.$subval.')' ; break; 
+			} 
+			break;						
+		    case 10: 
+			$key="ImageSize";
+			switch($subval) 
+			{
+				case 0: $data.='Large'; break;
+				case 1: $data.='Medium'; break;
+				case 2: $data.='Small'; break;
+				//    default : $data.=$subval.' ?';
+			}
+			break;							
+		    case 11:
+			$key="ShootingMode";
+			switch($subval) 
+			{
+				case 0: $data.="Full Auto"; break;
+				// no display if  off case 1: $data.="Manual"; break;
+				case 2: $data.="Landscape"; break;
+				case 3: $data.="Fast Shutter"; break;
+				case 4: $data.="Slow Shutter"; break;
+				case 5: $data.="Night"; break;
+				case 6: $data.="Black & White"; break;
+				case 7 : $data.="Sepia"; break;
+				case 8: $data.="Portrait"; break;
+				case 9: $data. "Sports"; break;
+				case 10: $data. "Macro / Close-Up"; break;
+				case 11: $data.="Pan Focus"; break;
+				//  default : $data.=$subval.' ?';
+			}
+			break;
+		   // Contrast, Saturation, Sharpness are only interessting for those shooting direclty in JPG
+		   // Otherwise, it display the RAW value, which are not very relevant IMHO as further enhancements are made in JPG processing
+		   // That's why they are commented 
+		   /*case 13:
+			$key="Contrast";
+			$data.=$subval; 
+			break;			 
+		    case 14:
+			$key="Saturation";
+			$data.=$subval; 
+			break;										 
+		    case 15:
+			$key="Sharpness";
+			if ($subval > 3200) {$subval ='Normal';}
+			$data.=$subval; 
+			break; */
+		    case 17:
+			$key = "MeteringMode";
+			switch($subval)
+			{
+				case 0: $data ='Default'; break;
+				case 1: $data ='Spot'; break;
+				case 2: $data ='Average'; break;
+				case 3: $data ='Evaluative'; break;
+				case 4: $data ='Partial'; break;
+				case 5: $data ='weighted average'; break;
+				default : $data.=$subval.' ?';
+			}  
+			break;
+		    case 19:
+			$key="AFPointSelected"; 
+			// seems to be valid only for compact cameras, own tests with EOS camera already retrieve 0.
+			if ($isEOS) 
+			{ $data=''; }
+			else
+			{
+			    switch($subval) 
+			    {
+				case 0: $data = "";
+				case 0x3000: $data="None (Manual Focus)"; break;
+				case 0x3001: $data="Auto Selected"; break;
+				case 0x3002: $data="Right"; break;
+				case 0x3003: $data="Centre"; break;
+				case 0x3004: $data="Left" ; break;
+				case 0x4001: $data="Auto AF point Selection"; break;
+				case 0x2005: $data="Manual AF point Selected"; break;
+				default: $data="Reserved (".$subval.")"; break;
+			    }
+			}			
+			break;
+		    case 20:
+			$key="ExposureProgram";
+			switch($subval) 
+			{
+				case 0: $data.='Auto'; break;
+				case 1: $data.='Program'; break;
+				case 2: $data.='Shutter priority (Tv)'; break;
+				case 3: $data.='Aperture Priority (Av)'; break;
+				case 4: $data.='Manual'; break;
+				case 5: $data.='Depth-of-field'; break;
+				case 6: $data.='M-Dep'; break;
+				case 7: $data.='Bulb'; break;
+			}
+			break;			 
+		    case 23: // proceed both max and min focal length together
+			$key="Max. Focal";
+			if ($subval > 4000)	{ $subval /= 1000;}   // for compact cameras
+			$maxLen=$subval; 
+			$data=""; // do not show the max len
+			//$data.=$subval." mm"; 
+			break;										 
+		    case 24:
+			// $key="Min. Focal ";
+			if ($subval > 4000)	{ $subval /= 1000;}  // for compact cameras
+			if ($subval <> $maxLen)
+			{
+		  		$key="LensFocalRange";
+				$data=$subval."-".$maxLen."mm";
+			}
+			else 
+			{
+				$key="FixedFocalLens";
+				$data.=$subval." mm";
+			}
+			break;			    
+		    case 28:
+			$key="FlashActivity";
+			switch($subval) 
+			{
+				// no display if  off case 0: $data.="Not fired"; break;
+				case 1: $data.=" Fired"; break;
+				//     default : $data.=$subval.' ?';
+			}
+			break;	 
+		    case 29:
+			$key="FlashDetail";
+			switch($subval) 
+			{
+				case 4: $data="FP sync enabled"; break;
+				case 7: $data="2nd(rear)-curtain sync used"; break;
+				case 11: $data="FP sync used"; break;
+				case 13: $data="internal flash"; break;
+				case 14: $data="External E-TTL"; break;		
+			}
+			break;			
+		    case 34:
+			$key ='Stabilization'; // for compact?
+			switch($subval) 
+			{
+				case 0: $data.='Off'; break;
+				case 1: $data.='On'; break;
+				case 2: $data.='On, Shot Only'; break;
+				case 3: $data.='On, Panning';break;
+				//	  default : $data.=$subval.' ?';
+			}
+			break;				  
+		    case 39: 
+                	$key ='SpotMeteringMode';
+			switch($subval) 
+			{
+				case 0: $data.='Center'; break;
+				case 1: $data.='AF point'; break;
+				//  default : $data.=$subval.' ?';
+			}
+			break;
+		} // switch($Elem)
+
+		if ($data!="" )
+		{
+			if (isset($lang['exif_field_'.$key]))
+	        	{ 	$key = $lang['exif_field_'.$key];}
+			$tpl_meta['lines'][$key] = $data;; 
+		} 
+	} // foreach
+  } // if(is_array)
+} // function
+
+/*    ///////////////////////////////// 
+	copy  in config_local.inc.php
+  ///////////////////////////////////
+// exemple of interesting parameters 
+$conf['show_exif_fields'] = array(
+	'Model',
+	'ExposureTime',
+	'ExposureBiasValue',
+	'FocalLength',
+    'FNumber', 
+    'ISOSpeedRatings', 
+    'DateTimeOriginal',
+    'Flash',
+    'Lens',
+    'ModeArray', 
+    'UndefinedTag:0x0095'
+)
+
+ ///////////////////////////////// 
+    Traduction Francaise
+  Copier ce qui suit à la fin de : language/fr_FR/local.lang.php à l'aide de LocalFiles Editor, onglet "Language"
+  ///////////////////////////////////
+// Exif généralistes.
+$lang['exif_field_Make'] = 'Marque';
+$lang['exif_field_Model'] = 'Modèle';
+$lang['exif_field_ExposureCompensation'] = 'Correction Expo';
+$lang['exif_field_ExposureTime'] = 'Vitesse';
+$lang['exif_field_ShutterSpeed'] = 'Vitesse';
+$lang['exif_field_Aperture'] = 'Ouverture diaph.';
+$lang['exif_field_MaxAperture'] = 'Ouverture max';
+$lang['exif_field_FocalLength'] = 'Focale';
+$lang['exif_field_LensName'] = 'Objectif';
+$lang['exif_field_TakenDate'] = 'Le';
+// Exif plus spécifiques.
+$lang['exif_field_ImageQuality'] = 'Qualité Image';
+$lang['exif_field_SelfTimer'] = 'Retardateur';
+$lang['exif_field_Drive'] = "Mode d'acquisition";
+$lang['exif_field_FocusMode'] = 'Mode focus';
+$lang['exif_field_ImageSize'] = 'Taille image';
+$lang['exif_field_ShootingMode'] =  'Mode auomatique';
+$lang['exif_field_Contrast'] = 'Contraste';
+$lang['exif_field_Sharpness'] = 'Netteté';
+$lang['exif_field_MeteringMode'] = 'Mesure Expo.';
+$lang['exif_field_AFPointSelected'] = 'Collimateur AF';
+$lang['exif_field_ExposureProgram'] = 'Prog. Expo';
+$lang['exif_field_LensFocalRange'] = 'Objectif zoom';
+$lang['exif_field_FixedFocalLens'] = 'Objectif fixe';
+$lang['exif_field_FlashActivity'] = 'Flash Opt';
+$lang['exif_field_FlashDetail'] = 'Détail param flash';
+$lang['exif_field_Stabilization'] = 'Stabilisation';
+$lang['exif_field_SpotMeteringMode'] = 'Mesure spot';
+
+ ///////////////////////////////// 
+    English translation
+  copy at the end of file : language/en_EN/local.lang.php with LocalFiles Editor
+  ///////////////////////////////////
+//translate exif properties in English
+// normal exif
+$lang['exif_field_Make'] = 'Make';
+$lang['exif_field_Model'] = 'Model';
+$lang['exif_field_ExposureCompensation'] = 'Exposure Compensation';
+$lang['exif_field_ExposureTime'] = 'Exposure Time';
+$lang['exif_field_ShutterSpeed'] = 'Shutter Speed';
+$lang['exif_field_Aperture'] = 'Aperture';
+$lang['exif_field_MaxAperture'] = 'Max Aperture';
+$lang['exif_field_FocalLength'] = 'Focal Length';
+$lang['exif_field_LensName'] = 'Lens Name';
+$lang['exif_field_TakenDate'] = 'Taken Date';
+// further exif from MakerNotes
+$lang['exif_field_ImageQuality'] = 'Image Quality';
+$lang['exif_field_SelfTimer'] = 'Self Timer';
+$lang['exif_field_Drive'] = "Drive";
+$lang['exif_field_FocusMode'] = 'Focus Mode';
+$lang['exif_field_ImageSize'] = 'Image Size';
+$lang['exif_field_ShootingMode'] =  'Shooting Mode';
+$lang['exif_field_Contrast'] = 'Contrast';
+$lang['exif_field_Sharpness'] = 'Sharpness';
+$lang['exif_field_MeteringMode'] = 'Metering Mode';
+$lang['exif_field_AFPointSelected'] = 'AF Point Selected';
+$lang['exif_field_ExposureProgram'] = 'Exposure Program';
+$lang['exif_field_LensFocalRange'] = 'Lens Focal Range';
+$lang['exif_field_FixedFocalLens'] = 'Fixed Focal Lens';
+$lang['exif_field_FlashActivity'] = 'Flash Activity';
+$lang['exif_field_FlashDetail'] = 'Flash Detail';
+$lang['exif_field_Stabilization'] = 'Stabilization';
+$lang['exif_field_SpotMeteringMode'] = 'Spot Metering Mode';
+
+///////////////////////////////
+/// Template/Plugin ajustment
+// If you are using the template 'Look Like GBO' and enabling the EXIF as tooltip instead of below the picture, you may need to ajust the width of this tooltip: 
+// e.g. 260px instead of 150
+// \plugins\look_like_gbo2\css\sweettitles.css
+// div#toolTip {position:absolute;z-index:1000;width:260px;background:#000;color:gray;border:2px solid #d3d3d3;padding:5px;min-height:1em;-moz-border-radius:5px}
+
+*/
+?>
