[Linpha-cvs] SF.net SVN: linpha: [4916] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2008-04-06 21:38:46
|
Revision: 4916 http://linpha.svn.sourceforge.net/linpha/?rev=4916&view=rev Author: fangehrn Date: 2008-04-06 14:38:41 -0700 (Sun, 06 Apr 2008) Log Message: ----------- 2008-04-06 flo * metadata cleanups and improvements Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/maintenance_import.php trunk/linpha2/docs/dev/TODO.txt trunk/linpha2/lib/classes/linpha.exiftool.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/classes/linpha.pjmt.class.php trunk/linpha2/lib/classes/linpha.view.album.class.php trunk/linpha2/lib/classes/linpha.view.image.class.php trunk/linpha2/lib/include/sql/sql.data.php trunk/linpha2/lib/include/sql/sql.tables.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2008-04-02 20:54:22 UTC (rev 4915) +++ trunk/linpha2/ChangeLog 2008-04-06 21:38:41 UTC (rev 4916) @@ -1,4 +1,7 @@ +2008-04-06 flo + * metadata cleanups and improvements + 2008-04-02 flo * adapted static album/image view to fit new layout Modified: trunk/linpha2/admin/maintenance_import.php =================================================================== --- trunk/linpha2/admin/maintenance_import.php 2008-04-02 20:54:22 UTC (rev 4915) +++ trunk/linpha2/admin/maintenance_import.php 2008-04-06 21:38:41 UTC (rev 4916) @@ -31,13 +31,13 @@ ini_set("max_execution_time", "6000"); -$array_meta = Array('exif','iptc','xmp'); +$array_meta = array('exif','iptc','xmp'); -if( isset($_POST['cmd']) && $_POST['cmd']=='import') +if ( isset($_POST['cmd']) && $_POST['cmd']=='import') { echo '<h1 class="linStyle">'.i18n("Running Import...").'</h1>'; - if(!isset($_REQUEST['album_select']) OR $_REQUEST['album_select'][0]=='all') + if (!isset($_REQUEST['album_select']) OR $_REQUEST['album_select'][0]=='all') { $all_albums = true; } @@ -50,17 +50,17 @@ /** * import */ - if($_REQUEST['index_import']=='index') + if ($_REQUEST['index_import']=='index') { echo '<h2 class="linStyle">'.i18n("Directory Import").'</h2>'; - if($all_albums) + if ($all_albums) { echo i18n("Parsing All Directories...").'<br />'; LinImport::updateDir( $parent_id = 0, $recursive = true, $dryrun = false ); } else { - foreach($_REQUEST['album_select'] AS $key=>$value) + foreach ($_REQUEST['album_select'] AS $key=>$value) { $data = $GLOBALS['linpha']->db->GetRow("SELECT name FROM ".LIN_PREFIX."photos WHERE id = '".LinSql::linAddslashes($value)."'"); echo i18n("Parsing Directory:").' '.$data['name'].'<br />'; @@ -68,7 +68,7 @@ } } - if( isset($GLOBALS['linpha']->template->output['sys_log']) ) + if ( isset($GLOBALS['linpha']->template->output['sys_log']) ) { echo $GLOBALS['linpha']->template->output['sys_log']; unset($GLOBALS['linpha']->template->output['sys_log']); @@ -86,13 +86,13 @@ * we would have to take care to the script backwards, * that means first of the depest subfolder until we're on top */ - if($_REQUEST['index_thumbnails']!='no' OR isset($_REQUEST['index_thumbnails_delete'])) + if ($_REQUEST['index_thumbnails']!='no' OR isset($_REQUEST['index_thumbnails_delete'])) { echo '<h2 class="linStyle">'.i18n("Thumbnails").'</h2>'; $thumbnail = new LinImage(); - if($_REQUEST['index_thumbnails']=='recreate') + if ($_REQUEST['index_thumbnails']=='recreate') { $_GET['force'] = true; } @@ -100,17 +100,17 @@ /** * all albums selected */ - if($all_albums) + if ($all_albums) { /** * delete thumbnails */ - if( isset($_REQUEST['index_thumbnails_delete']) ) + if ( isset($_REQUEST['index_thumbnails_delete']) ) { echo i18n("Delete All Existing Thumbnails...").'<br />'; $thumbcachepath = LinSql::getPath('cache').'/thumb'; LinFilesys::rm_rf( $thumbcachepath ); // all subfolders will automatically be recreated on each image access - if(file_exists($thumbcachepath)) + if (file_exists($thumbcachepath)) { echo i18n("Warning while deleting file/folder, check permissions!").'<br />'; } @@ -123,7 +123,7 @@ /** * set query string for create/recreate thumbnails */ - if($_REQUEST['index_thumbnails']!='no') + if ($_REQUEST['index_thumbnails']!='no') { echo '<h3>'.i18n("Parsing All Directories...").'</h3><br />'; $createthumbquery = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."photos WHERE img_type <> '0' AND img_type <> '9999999'"); @@ -146,13 +146,13 @@ /** * delete thumbnails */ - if( isset($_REQUEST['index_thumbnails_delete']) ) + if ( isset($_REQUEST['index_thumbnails_delete']) ) { echo i18n("Delete Thumbnails"); $query = $GLOBALS['linpha']->db->Execute($sql); while($data = $query->FetchRow()) { - if( LinImage::deleteCachedThumbnail($data['id'], $data['img_type'])) + if ( LinImage::deleteCachedThumbnail($data['id'], $data['img_type'])) { echo " ".$data['id'].","; } @@ -163,7 +163,7 @@ /** * set query string for create/recreate thumbnails */ - if($_REQUEST['index_thumbnails']!='no') + if ($_REQUEST['index_thumbnails']!='no') { $createthumbquery = $GLOBALS['linpha']->db->Execute($sql); } @@ -173,16 +173,16 @@ /** * now create thumbnails, $query has been set previously */ - if($_REQUEST['index_thumbnails']!='no') + if ($_REQUEST['index_thumbnails']!='no') { echo i18n("Create Thumbnail"); while($data = $createthumbquery->FetchRow()) { - if( ! $thumbnail->createThumbnail($data['id']) ) + if ( ! $thumbnail->createThumbnail($data['id']) ) { echo i18n("Error While Creating Thumbnail!")."<br />Error: ".$thumbnail->error_msg."<br />"; } - if( ! $thumbnail->isCached ) // thumbnail wasn't cached -> now created! + if ( ! $thumbnail->isCached ) // thumbnail wasn't cached -> now created! { echo " ".$data['id'].","; } @@ -202,9 +202,9 @@ */ $MetaData = new LinMetaData(); - foreach($array_meta AS $meta_value) + foreach($array_meta as $meta_value) { - if( isset( $_REQUEST['index_'.$meta_value] ) && + if ( isset($_REQUEST['index_'.$meta_value]) && ( $_REQUEST['index_'.$meta_value] == 'index' OR isset($_REQUEST['index_'.$meta_value.'_delete']) ) ) { echo '<h2 class="linStyle">'.i18n("File Indexing").' ('.strtoupper($meta_value).')</h2>'; @@ -212,12 +212,12 @@ /** * get imgids to indexing, if reindex is selected: delete these entries first */ - if($all_albums) + if ($all_albums) { echo i18n("All Directories selected").'<br />'; $query = $GLOBALS['linpha']->db->Execute("SELECT id, md5sum FROM ".LIN_PREFIX."photos WHERE img_type <> 0 AND img_type <> 9999999"); - while($data = $query->FetchRow()) + while ($data = $query->FetchRow()) { $array_meta_ids[$data['id']] = $data['md5sum']; } @@ -225,7 +225,7 @@ else { echo i18n("Directory selected:").' '; - foreach($_REQUEST['album_select'] AS $key=>$value) + foreach ($_REQUEST['album_select'] AS $key=>$value) { $data = $GLOBALS['linpha']->db->GetRow("SELECT name FROM ".LIN_PREFIX."photos WHERE id = '".LinSql::linAddslashes($value)."'"); echo $data['name'].', '; @@ -233,7 +233,7 @@ $query = $GLOBALS['linpha']->db->Execute("SELECT id, md5sum FROM ".LIN_PREFIX."photos WHERE " . "parent_id = '".LinSql::linAddslashes($value)."' AND " . "img_type <> 0 AND img_type <> 9999999"); - while($data = $query->FetchRow()) + while ($data = $query->FetchRow()) { $array_meta_ids[$data['id']] = $data['md5sum']; } @@ -244,17 +244,17 @@ /** * delete first (if selected) */ - if( isset($_REQUEST['index_'.$meta_value.'_delete']) ) + if ( isset($_REQUEST['index_'.$meta_value.'_delete']) ) { - if( $all_albums ) + if ( $all_albums ) { echo i18n("Delete all index data").'<br />'; $GLOBALS['linpha']->db->Execute("DELETE FROM ".LIN_PREFIX."meta_".$meta_value); } - elseif( isset($array_meta_ids) ) + elseif (isset($array_meta_ids)) { echo i18n("Delete index data of selected directories").'<br />'; - foreach($array_meta_ids AS $id=>$md5sum) + foreach ($array_meta_ids AS $id=>$md5sum) { $GLOBALS['linpha']->db->Execute("DELETE FROM ".LIN_PREFIX."meta_".$meta_value." WHERE md5sum = '".$md5sum."'"); } @@ -264,31 +264,17 @@ /** * index image, parse all saved ids */ - if( isset($array_meta_ids) && $_REQUEST['index_'.$meta_value] == 'index' ) + if ( isset($array_meta_ids) && $_REQUEST['index_'.$meta_value] == 'index' ) { echo i18n("Index Image"); - foreach($array_meta_ids AS $id=>$md5sum) + foreach ($array_meta_ids as $id=>$md5sum) { - $query = $GLOBALS['linpha']->db->Execute("SELECT md5sum ". - "FROM ".LIN_PREFIX."meta_exif WHERE md5sum = '".$md5sum."'"); - - if( $query->EOF) // not a single value returned + if (LinMetaData::fileNeedsIndexing($md5sum, LIN_PREFIX."meta_".$meta_value)) { $full_filename = LinSql::getFullImagePath($id); - - switch($meta_value) - { - case 'exif': - $MetaData->saveData('exif',$full_filename,$md5sum); - break; - case 'iptc': - $MetaData->saveData('iptc',$full_filename,$md5sum); - break; - case 'xmp': - $MetaData->saveData('xmp',$full_filename,$md5sum); - break; - } + + $MetaData->saveMetaDataToDatabase($meta_value, $full_filename, $md5sum); echo " ".$id.","; flush(); @@ -333,7 +319,7 @@ <?php foreach($array_meta AS $value) { - if($GLOBALS['linpha']->sql->config->value['sys_image_'.$value]) + if ($GLOBALS['linpha']->sql->config->value['sys_image_'.$value]) { echo strtoupper($value).":<br />"; echo '<input type="checkbox" id="index_'.$value.'_deletefirst" name="index_'.$value.'_delete" value="delete" /><label for="index_'.$value.'_deletefirst"> '.i18n("Delete First").'</label><br />'; @@ -359,7 +345,7 @@ /** * import */ - if($linpha->sql->config->value['sys_import_autoimport']) + if ($linpha->sql->config->value['sys_import_autoimport']) { LinImport::updateDir( $parent_id = 0, $recursive = true, $dryrun = true ); } @@ -368,7 +354,7 @@ * flush buffer */ echo '<b>'.i18n("Following files/folders needs updating:").'</b><br />'; - if( isset($GLOBALS['linpha']->template->output['sys_log']) ) + if ( isset($GLOBALS['linpha']->template->output['sys_log']) ) { echo $GLOBALS['linpha']->template->output['sys_log']; unset($GLOBALS['linpha']->template->output['sys_log']); @@ -395,7 +381,7 @@ $thumbnail->setFileInformation(); - if( ! $thumbnail->isCached ) + if ( ! $thumbnail->isCached ) { $num++; } @@ -414,7 +400,7 @@ foreach($array_meta AS $value) { - if($GLOBALS['linpha']->sql->config->value['sys_image_'.$value]) + if ($GLOBALS['linpha']->sql->config->value['sys_image_'.$value]) { $nr_indexed = $GLOBALS['linpha']->db->GetRow("SELECT count(md5sum) " . "AS number_idx " . Modified: trunk/linpha2/docs/dev/TODO.txt =================================================================== --- trunk/linpha2/docs/dev/TODO.txt 2008-04-02 20:54:22 UTC (rev 4915) +++ trunk/linpha2/docs/dev/TODO.txt 2008-04-06 21:38:41 UTC (rev 4916) @@ -27,10 +27,11 @@ - compress javascripts (prototype and scriptaculous) they are now nearly 200KB big +- re-add getId3 as fallback if exiftool is not available + (video thumbnail and video playback) + ## Big Todos -- Use Effekts is sometimes hardcoded, make use of config - setting sys_style_image_useeffects in all places where used - Installer - OSX testing @@ -58,6 +59,7 @@ Open questions ############################################################################ + - thumbnail size, set a max size (for example 150px), to be able to switch the size on fly @@ -82,6 +84,9 @@ DONE ############################################################################ +- Use Effekts is sometimes hardcoded, make use of config + setting sys_style_image_useeffects in all places where used + - Switch to strict mode - we should changed html type to strict mode: old: Modified: trunk/linpha2/lib/classes/linpha.exiftool.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.exiftool.class.php 2008-04-02 20:54:22 UTC (rev 4915) +++ trunk/linpha2/lib/classes/linpha.exiftool.class.php 2008-04-06 21:38:41 UTC (rev 4916) @@ -143,11 +143,31 @@ */ public function readMetaDataFromFile($metatype, $filename) { - $meta =""; - $return=""; + $meta = ""; + $return = ""; $metaArray = array(); + + /** + * used inputs: iptc, xmp, exif, exifgps + * use the switch statement to be sure that no invalid input is used + */ + switch($metatype) + { + case 'iptc': + $metatypeInput = 'iptc'; + break; + case 'xmp': + $metatypeInput = 'xmp'; + break; + case 'exifgps': + $metatypeInput = 'gps'; + break; + default: + $metatypeInput = 'exif'; + break; + } - $parameters = "-$metatype:all " . // Get all Tag Information + $parameters = "-$metatypeInput:all " . // Get all Tag Information "-s " . // Print tag names instead of descr. "-t " . // Use tab \t as delimiter "-fast " . // Do not read to EOF @@ -167,61 +187,47 @@ * Create usable array information by cycling and splitting * all information */ - foreach($meta as $value) + foreach($meta as $row) { - $temp = explode("\t", $value); - $metaArray[trim($temp['0'])] = @trim($temp['1']); - } - - return $metaArray; - } - - /** - * Save all MetaData to database - * @param string $filename filename to parse for MetaData - * @param string $md5sum md5sum of file - * @param string $tag save EXIF, IPTC or XMP MetaData - */ - public function saveMetaData($filename, $md5sum, $tag) - { - - $dataArray = LinExifTool::readMetaDataFromFile($tag, $filename); - - //echo '<pre>', print_r($dataArray), '</pre>'; - - - $str_columns = "md5sum, "; - $str_values = "'" . $md5sum . "', "; - - if(is_array($dataArray)) - { + $temp = explode("\t", $row); + + $key = trim($temp['0']); + $value = $temp['1']; + /** - * Lower array data to make it compareable to LinExifTool::$metaTags + * normalize tag names + * http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html */ - $lowerDataArray = array_change_key_case($dataArray, 'LOWER_CASE'); - - /** - * Search for valid and filled tags - */ - foreach($this->defined_fields[$tag] AS $key => $value) + switch($key) { - if(array_key_exists($key, $lowerDataArray)) - { - $str_columns .= str_replace("_", "-", $key) . ', '; - $str_values .= "'".trim($lowerDataArray[$key])."', "; - //$str_values .= "'".HTML_UTF8_Escape(trim($lowerDataArray[$key]))."', "; - } + case "Comment": + $key = "JPEGComment"; + break; + case "ModifyDate": + $key = "DateTime"; + break; + case "CreateDate": + $key = "DateTimeDigitized"; + break; + case "ISO": + $key = "ISOSpeedRatings"; + break; + case "ExifImageWidth": + $key = "PixelXDimension"; + break; + case "ExifImageHeight": + $key = "PixelYDimension"; + break; + case "FocalLengthIn35mmFormat": + $key = "FocalLengthIn35mmFilm"; + break; } + + + $metaArray[$key] = $value; + } - /** - * Remove last two signs (the comma and the space) which we add to much - */ - $str_columns = substr($str_columns, 0, strlen($str_columns) - 2); - $str_values = substr($str_values, 0, strlen($str_values) - 2); - - $GLOBALS['linpha']->db->Execute("INSERT into ".LIN_PREFIX."meta_$tag " . - "(" . $str_columns . ") VALUES (" . $str_values . ")"); - } + return $metaArray; } /** @@ -291,7 +297,7 @@ * @return array fileds already selected to be used (defined_fields) * and also available fields from $metaTags (available_fields) * @author bzrudi,flo - */ + public function setMetaFields($metatype) { @@ -300,7 +306,7 @@ * without the md5sum entry. * MetaColumns() returns the keys always uppercase independent * of ADODB_ASSOC_CASE setting, so strtolower() them. - */ + $array = $GLOBALS['linpha']->db->MetaColumns(LIN_PREFIX."meta_".$metatype); $this->defined_fields[$metatype] = array (); @@ -317,7 +323,7 @@ /** * Create available_fields, mostly used in admin section where one will * setup the MetaData fields to index. - */ + foreach (LinExifTool::$metaTags[$metatype] AS $key => $value) { if (!isset ($this->defined_fields[$metatype][$key])) @@ -325,7 +331,7 @@ $this->available_fields[$metatype][$key] = $value; } } - } + }*/ /** * Just get DateTimeOriginal from EXIF header @@ -359,186 +365,185 @@ * @param none * @return none * @author bzrudi - */ + public static $metaTags = array( 'xmp' => array( - //Iptc4xmpCore schema tags - 'countrycode' => 'Country Code', - 'intellectualgenre' => 'Intellectual Genre', - 'location' => 'Location', - 'scene' => 'Scene', - 'subjectcode' => 'Subject Code', - - //Dublin Core schema tags - 'contributor' => 'Contributor', - 'coverage' => 'Coverage', - 'creator' => 'Creator', - 'date' => 'Date', - 'description' => 'Description', - 'format' => 'Format', - 'identifier' => 'Identifier', - 'publisher' => 'Publisher', - 'rights' => 'Rights', - 'subject' => 'Subject', - 'title' => 'Title', - - //Adobe Photoshop schema tags - 'authorsposition' => 'Authors Position', - 'captionwriter' => 'Caption Writer', - 'category' => 'Category', - 'city' => 'City', - 'colormode' => 'Color Mode', - 'country' => 'Country', - 'credit' => 'Credit', - //'datecreated' => 'DateCreated', - 'headline' => 'Headline', - 'iccprofilename' => 'ICC Profile Name', - 'instructions' => 'Instructions', - 'source' => 'Source', - 'state' => 'State', - 'supplementalcategories' => 'Supplemental Categories', - 'transmissionreference' => 'Transmission Reference', - 'urgency' => 'Urgency' - + //Iptc4xmpCore schema tags + 'countrycode' => '', + 'intellectualgenre' => '', + 'location' => '', + 'scene' => '', + 'subjectcode' => '', + + //Dublin Core schema tags + 'contributor' => '', + 'coverage' => '', + 'creator' => '', + 'date' => '', + 'description' => '', + 'format' => '', + 'identifier' => '', + 'publisher' => '', + 'rights' => '', + 'subject' => '', + 'title' => '', + + //Adobe Photoshop schema tags + 'authorsposition' => '', + 'captionwriter' => '', + 'category' => '', + 'city' => '', + 'colormode' => '', + 'country' => '', + 'credit' => '', + //'datecreated' => '', + 'headline' => '', + 'iccprofilename' => '', + 'instructions' => '', + 'source' => '', + 'state' => '', + 'supplementalcategories' => '', + 'transmissionreference' => '', + 'urgency' => '' ), //IPTC schema tags 'iptc' => array( - //IPTC ApplicationRecord Tags - 'applicationrecordversion' => 'Application Record Version', - 'objecttypereference' => 'Object Type Reference', - 'objectattributereference' => 'Object Attribute Reference', - 'objectname' => 'Object Name', - 'objectcycle' => 'Object Cycle', - 'editstatus' => 'Edit Status', - 'subjectreference' => 'Subject Reference', - //'category' => 'Category', - 'supplementalcategories' => 'Supplemental Categories', - 'keywords' => 'Keywords', - 'specialinstructions' => 'Special Instructions', - 'datecreated' => 'Date Created', - 'timecreated' => 'Time Created', - 'by_line' => 'By-line', - 'by_linetitle' => 'By-line Title', - //'city' => 'City', - 'sub_location' => 'Sub-location', - 'province_state' => 'Province-State', - 'country_primarylocationcode' => 'Country-Primary Location Code', - 'country_primarylocationname' => 'Country-Primary Location Name', - 'originaltransmissionreference' => 'Original Transmission Reference', - //'headline' => 'Headline', - //'credit' => 'Credit', - //'source' => 'Source', - 'copyrightnotice' => 'Copyright Notice', - 'contact' => 'Contact', - 'caption_abstract' => 'Caption-Abstract', - 'writer_editor' => 'Writer-Editor', - 'originatingprogram' => 'Originating Program', - 'releasedate' => 'Release Date' + //IPTC ApplicationRecord Tags + 'applicationrecordversion' => '', + 'objecttypereference' => '', + 'objectattributereference' => '', + 'objectname' => '', + 'objectcycle' => '', + 'editstatus' => '', + 'subjectreference' => '', + //'category' => '', + 'supplementalcategories' => '', + 'keywords' => '', + 'specialinstructions' => '', + 'datecreated' => '', + 'timecreated' => '', + 'by_line' => '', + 'by_linetitle' => '', + //'city' => '', + 'sub_location' => '', + 'province_state' => '', + 'country_primarylocationcode' => '', + 'country_primarylocationname' => '', + 'originaltransmissionreference' => '', + //'headline' => '', + //'credit' => '', + //'source' => '', + 'copyrightnotice' => '', + 'contact' => '', + 'caption_abstract' => '', + 'writer_editor' => '', + 'originatingprogram' => '', + 'releasedate' => '' ), //EXIF schema tags 'exif' => array( - //IFD0 - 'processingsoftware' => 'Processing Software', - 'imagewidth' => 'Image Width', - 'imagelength' => 'Image Length', - 'bitspersample' => 'Bits Per Sample', - 'compression' => 'Compression', - 'photometricinterpretation' => 'Photometric Interpretation', - 'thresholding' => 'Thresholding', - 'cellwidth' => 'Cell Width', - 'celllength' => 'Cell Length', - 'fillorder' => 'Fill Order', - 'documentname' => 'Document Name', - 'imagedescription' => 'Image Description', - 'make' => 'Maker', - 'model' => 'Model', - 'orientation' => 'Orientation', - 'samplesperpixel' => 'Samples Per Pixel', - 'rowsperstrip' => 'Rows Per Strip', - 'minsamplevalue' => 'Min Sample Value', - 'maxsamplevalue' => 'Max Sample Value', - 'xresolution' => 'X Resolution', - 'yresolution' => 'Y Resolution', - 'planarconfiguration' => 'Planar Configuration', - 'pagename' => 'Page Name', - 'xposition' => 'X Position', - 'yposition' => 'Y Position', - 'grayresponseunit' => 'Gray Response Unit', - 'resolutionunit' => 'Resolution Unit', - 'pagenumber' => 'Page Number', - 'software' => 'Software', - 'modifydate' => 'Modify Date', - 'artist' => 'Artist', - 'hostcomputer' => 'Host Computer', - 'predictor' => 'Predictor', - 'whitepoint' => 'White Point', - 'primarychromaticities' => 'Primary Chromaticities', - 'halftonehints' => 'Halftone Hints', - 'tilewidth' => 'Tile Width', - 'tilelength' => 'Tile Length', - 'ycbcrcoefficients' => 'YCbCr Coefficients', - 'ycbcrsubsampling' => 'YCbCr Sub Sampling', - 'ycbcrpositioning' => 'YCbCr Positioning', - 'referenceblackwhite' => 'Reference Black White', - 'relatedimagefileformat' => 'Related Image File Format', - 'relatedimagewidth' => 'Related Image Width', - 'relatedimagelength' => 'Related Image Length', - 'rating' => 'Rating', - 'ratingpercent' => 'Rating Percent', - 'copyright' => 'Copyright', - - //ExifIFD - 'exposuretime' => 'Exposure Time', - 'fnumber' => 'F Number', - 'exposureprogram' => 'Exposure Program', - 'spectralsensitivity' => 'Spectral Sensitivity', - 'iso' => 'ISO', - 'timezoneoffset' => 'Time Zone Offset', - 'selftimermode' => 'Self Timer Mode', - 'exifversion' => 'Exif Version', - 'datetimeoriginal' => 'Date Time Original', - 'createdate' => 'Create Date', - 'componentsconfiguration' => 'Components Configuration', - 'compressedbitsperpixel' => 'Compressed Bits Per Pixel', - 'shutterspeedvalue' => 'Shutter Speed Value', - 'aperturevalue' => 'Aperture Value', - 'brightnessvalue' => 'Brightness Value', - 'exposurecompensation' => 'Exposure Compensation', - 'maxaperturevalue' => 'Max Aperture Value', - 'subjectdistance' => 'Subject Distance', - 'meteringmode' => 'Metering Mode', - 'lightsource' => 'Light Source', - 'flash' => 'Flash', - 'focallength' => 'Focal Length', - 'imagenumber' => 'Image Number', - 'securityclassification' => 'Security Classification', - 'imagehistory' => 'Image History', - 'subjectlocation' => 'Subject Location', - 'exposureindex' => 'Exposure Index', - 'sensingmethod' => 'Sensing Method', - 'filesource' => 'File Source', - 'scenetype' => 'Scene Type', - 'cfapattern' => 'CFA Pattern', - 'customrendered' => 'Custom Rendered', - 'exposuremode' => 'Exposure Mode', - 'whitebalance' => 'White Balance', - 'digitalzoomratio' => 'Digital Zoom Ratio', - 'focallengthin35mmformat' => 'Focal Length In 35mm Format', - 'scenecapturetype' => 'Scene Capture Type', - 'gaincontrol' => 'Gain Control', - 'contrast' => 'Contrast', - 'saturation' => 'Saturation', - 'sharpness' => 'Sharpness', - 'subjectdistancerange' => 'Subject Distance Range', - 'gamma' => 'Gamma' + //IFD0 + 'processingsoftware' => '', + 'imagewidth' => '', + 'imagelength' => '', + 'bitspersample' => '', + 'compression' => '', + 'photometricinterpretation' => '', + 'thresholding' => '', + 'cellwidth' => '', + 'celllength' => '', + 'fillorder' => '', + 'documentname' => '', + 'imagedescription' => '', + 'make' => '', + 'model' => '', + 'orientation' => '', + 'samplesperpixel' => '', + 'rowsperstrip' => '', + 'minsamplevalue' => '', + 'maxsamplevalue' => '', + 'xresolution' => '', + 'yresolution' => '', + 'planarconfiguration' => '', + 'pagename' => '', + 'xposition' => '', + 'yposition' => '', + 'grayresponseunit' => '', + 'resolutionunit' => '', + 'pagenumber' => '', + 'software' => '', + 'modifydate' => '', + 'artist' => '', + 'hostcomputer' => '', + 'predictor' => '', + 'whitepoint' => '', + 'primarychromaticities' => '', + 'halftonehints' => '', + 'tilewidth' => '', + 'tilelength' => '', + 'ycbcrcoefficients' => '', + 'ycbcrsubsampling' => '', + 'ycbcrpositioning' => '', + 'referenceblackwhite' => '', + 'relatedimagefileformat' => '', + 'relatedimagewidth' => '', + 'relatedimagelength' => '', + 'rating' => '', + 'ratingpercent' => '', + 'copyright' => '', + + //ExifIFD + 'exposuretime' => '', + 'fnumber' => '', + 'exposureprogram' => '', + 'spectralsensitivity' => '', + 'iso' => '', + 'timezoneoffset' => '', + 'selftimermode' => '', + 'exifversion' => '', + 'datetimeoriginal' => '', + 'createdate' => '', + 'componentsconfiguration' => '', + 'compressedbitsperpixel' => '', + 'shutterspeedvalue' => '', + 'aperturevalue' => '', + 'brightnessvalue' => '', + 'exposurecompensation' => '', + 'maxaperturevalue' => '', + 'subjectdistance' => '', + 'meteringmode' => '', + 'lightsource' => '', + 'flash' => '', + 'focallength' => '', + 'imagenumber' => '', + 'securityclassification' => '', + 'imagehistory' => '', + 'subjectlocation' => '', + 'exposureindex' => '', + 'sensingmethod' => '', + 'filesource' => '', + 'scenetype' => '', + 'cfapattern' => '', + 'customrendered' => '', + 'exposuremode' => '', + 'whitebalance' => '', + 'digitalzoomratio' => '', + 'focallengthin35mmformat' => '', + 'scenecapturetype' => '', + 'gaincontrol' => '', + 'contrast' => '', + 'saturation' => '', + 'sharpness' => '', + 'subjectdistancerange' => '', + 'gamma' => '' ) - ); + );*/ } /* vi: set ts=4 sw=4 sts=4 */ -?> +?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2008-04-02 20:54:22 UTC (rev 4915) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2008-04-06 21:38:41 UTC (rev 4916) @@ -30,7 +30,8 @@ class LinMetaData { - public $defined_fields, $available_fields, $objMetaTool; + //public $defined_fields, $available_fields, + public $objMetaTool; private $cachedFieldNames, $cachedFieldIds, $cachedSelectedFieldNames; @@ -41,12 +42,12 @@ { if($GLOBALS['linpha']->sql->config->value['sys_import_use_exiftool']) { - include_once LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php'; + require_once LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php'; $this->objMetaTool = new LinExifTool(); } else { - include_once LINPHA_DIR.'/lib/classes/linpha.pjmt.class.php'; + require_once LINPHA_DIR.'/lib/classes/linpha.pjmt.class.php'; $this->objMetaTool = new LinPjmtTool(); } } @@ -706,7 +707,7 @@ /** * This method is used to setup the initial most useful defaults for the * MetaData tables EXIF/IPTC/XMP during creation and provides default - * Geodata (GPS) Tgas for the maps plugin + * Geodata (GPS) Tags for the maps plugin * @param string exif,iptc,xmp,gps * @return array with metadata information * @author bzrudi,flo @@ -766,43 +767,6 @@ ); break; - case 'gps': - return array ( - 'gpsversionid', - 'gpslatituderef', - 'gpslatitude', - 'gpslongituderef', - 'gpslongitude', - 'gpsaltituderef', - 'gpsaltitude', - 'gpstimestamp', - 'gpssatellites', - 'gpsstatus', - 'gpsmeasuremode', - 'gpsdop', - 'gpsspeedref', - 'gpsspeed', - 'gpstrackref', - 'gpstrack', - 'gpsimgdirectionref', - 'gpsimgdirection', - 'gpsmapdatum', - 'gpsdestlatituderef', - 'gpsdestlatitude', - 'gpsdestlongituderef', - 'gpsdestlongitude', - 'gpsdestbearingref', - 'gpsdestbearing', - 'gpsdestdistanceref', - 'gpsdestdistance', - 'gpsprocessingmethod', - 'gpsareainformation', - 'gpsdatestamp', - 'gpsdatetime', - 'gpsposition', - ); - break; - default: return array(); break; @@ -814,13 +778,13 @@ * @param string $metatype exif,iptc,xmp * @return none * @author bzrudi - */ + public function setMetaFields($metatype) { $this->objMetaTool->setMetaFields($metatype); $this->defined_fields = $this->objMetaTool->defined_fields; $this->available_fields = $this->objMetaTool->available_fields; - } + }*/ /** * This method is used to create any required MEtaData table @@ -828,9 +792,8 @@ * @param string $metatype exif,iptc,xmp * @return none * @author bzrudi,flo - * TODO cleanup + set required indexes! */ - public function createMetaDataTable($array, $metatype) + /*public function createMetaDataTable($array, $metatype) { if (!is_array($array)) { @@ -858,9 +821,8 @@ $value = str_replace("-", "_", strtolower($value)); $str .= strtolower($value) . " VARCHAR(255), "; } - /** - * remove last 2 signs (the comma and the space) - */ + + // remove last 2 signs (the comma and the space) $str = substr($str, 0, strlen($str) - 2) . ")"; } elseif (LIN_DB_TYPE == "postgres") @@ -874,13 +836,11 @@ $str .= "$value" . " TEXT, "; } - /** - * remove last 2 signs (the comma and the space) - */ + // remove last 2 signs (the comma and the space) $str = substr($str, 0, strlen($str) - 2) . ")"; } return $str; - } + }*/ /** * Save all Image GeoData (GPS) to database. @@ -895,6 +855,7 @@ */ public function massImportGeoData() { + $arrayGPSTags = $this->getDefaultMetaTags('gps'); $query = $GLOBALS['linpha']->db->Execute("SELECT id, md5sum FROM ".LIN_PREFIX."photos @@ -905,152 +866,96 @@ while($data = $query->FetchRow()) { $filename = LinSql::getFullImagePath($data['id']); - $dataArray = $this->objMetaTool->readMetaDataFromFile('exif', $filename); - - //echo '<pre>', print_r($dataArray), '</pre>'; - - $str_columns = "md5sum, "; - $str_values = "'".$data['id']."', "; - - if(is_array($dataArray)) + + if ($this->saveMetaDataToDatabase('exifgps', $filename, $data['md5sum'] )) { - /** - * Lower array data to make it compareable to $metaTags - */ - $lowerDataArray = array_change_key_case($dataArray, 'LOWER_CASE'); - - //echo '<pre>', print_r($lowerDataArray), '</pre>'; - - foreach($this->getDefaultMetaTags('gps') AS $key => $value) - { - if(array_key_exists($value, $lowerDataArray)) - { - - $str_columns .= str_replace("_", "-", $value) . ', '; - $str_values .= "'".trim($lowerDataArray[$value])."', "; - } - } - /** - * Remove last two signs (the comma and the space) which we add to much - */ - $str_columns = substr($str_columns, 0, strlen($str_columns) - 2); - $str_values = substr($str_values, 0, strlen($str_values) - 2); - - $GLOBALS['linpha']->db->Execute("INSERT INTO ".LIN_PREFIX."plugins_maps_image_geodata " . - "(" . $str_columns . ") VALUES (" . $str_values . ")"); - $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos " . - "SET geodata='1' WHERE md5sum='".$data['md5sum']."' "); + "SET geodata='1' WHERE md5sum='".$data['md5sum']."' "); } } } /** - * Save single Image GeoData (GPS) to database during import. - * Used in maps plugin if enabled. Other than massImportGeoData() we just - * get all "geodata" for a single image only. - * @param none - * @return none - * @author bzrudi + * Parse GPX data from file */ - public function singleImportGeoData($md5sum, $filename) + public function parseGpxFile($filename) { - /* - * Prevent double entries and prevent warnings + $parser = new GpxParser($filename); + } + + static public function fileNeedsIndexing($md5sum, $db_table) + { + /** + * Prevent double entries. We do this check at very first position + * to improve performance! */ $query = $GLOBALS['linpha']->db->Execute("SELECT md5sum " . - "FROM ".LIN_PREFIX."plugins_maps_image_geodata " . - "WHERE md5sum = '".$md5sum."' "); + "FROM " . $db_table . " " . + "WHERE md5sum = '" . $md5sum . "'"); - if($query->EOF) - { - $dataArray = $this->objMetaTool->readMetaDataFromFile('exif', $filename); - - $str_columns = "md5sum, "; - $str_values = "'".$md5sum."', "; - - if(is_array($dataArray)) - { - /** - * Lower array data to make it compareable to $metaTags - */ - - $lowerDataArray = array_change_key_case($dataArray, 'LOWER_CASE'); - - foreach($this->getDefaultMetaTags('gps') AS $key => $value) - { - if(array_key_exists($value, $lowerDataArray)) - { - $str_columns .= str_replace("_", "-", $value) . ', '; - $str_values .= "'".trim($lowerDataArray[$value])."', "; - } - } - - /** - * Remove last two signs (the comma and the space) which we add to much - */ - $str_columns = substr($str_columns, 0, strlen($str_columns) - 2); - $str_values = substr($str_values, 0, strlen($str_values) - 2); - - $GLOBALS['linpha']->db->Execute("INSERT INTO ".LIN_PREFIX."plugins_maps_image_geodata " . - "(" . $str_columns . ") VALUES (" . $str_values . ")"); - - $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos " . - "SET geodata='1' WHERE md5sum='".$md5sum."' "); - } - } + return $query->EOF; } /** - * Parse GPX data from file + * Save all MetaData to database + * @param string $tag save EXIF, IPTC or XMP MetaData + * @param string $filename filename to parse for MetaData + * @param string $md5sum md5sum of file + * @return none + * @author bzrudi, flo */ - public function parseGpxFile($filename) + public function saveMetaDataToDatabase($tag, $db_table, $filename, $md5sum) { - $parser = new GpxParser($filename); + $dataArray = $this->objMetaTool->readMetaDataFromFile($tag, $filename); - } - - /** - * Simple wrapper method for saveMetaData() - * @param string $what meta type exif,iptc,xmp - * @param string $filename filename - * @param string $md5sum md5sum of image - * @return none - * @author bzrudi,flo - */ - public function saveData($what, $filename, $md5sum) { + //echo '<pre>', print_r($dataArray), '</pre>'; + + if (!is_array($dataArray)) { + return false; + } + + $columns[] = "md5sum"; + $values[] = "'" . $md5sum . "'"; + /** - * Prevent double entries. We do this check at very first position - * to improve performance! - * Also we do not setMetaFields in the __contruct() because they may - * never be used + * Lower array data to make it compareable to LinExifTool::$metaTags + * this is about two times faster than calling strtolow($key) in the loop! */ - $query = $GLOBALS['linpha']->db->Execute("SELECT md5sum " . - "FROM " . LIN_PREFIX . "meta_" . $what . " " . - "WHERE md5sum = '" . $md5sum . "'"); + $lowerDataArray = array_change_key_case($dataArray, CASE_LOWER); - if($query->EOF) // not a single value returned + /** + * Search for valid and filled tags + */ + $hasData = false; + //foreach ($this->defined_fields[$tag] as $key => $value) + foreach ($lowerDataArray as $key => $value) { - /** - * define tags to index if not already done - */ - if(!isset ($this->defined_fields[$what])) + //if (array_key_exists($key, $lowerDataArray)) + if (isset(LinMetaData::$metaTags[$tag][$key])) { - $this->objMetaTool->setMetaFields($what); + //$columns .= str_replace("_", "-", $key) . ', '; // why? (flo) + $columns[] = $key; + + $value = trim($lowerDataArray[$key]); + if (!empty($value)) { + $hasData = true; + } + $values[] = "'".LinSql::linAddslashes($value)."'"; + //$str_values .= "'".HTML_UTF8_Escape(trim($lowerDataArray[$key]))."', "; } - switch($what) - { - case 'exif': - $this->objMetaTool->saveMetaData($filename, $md5sum, $what); - break; - case 'iptc': - $this->objMetaTool->saveMetaData($filename, $md5sum, $what); - break; - case 'xmp': - $this->objMetaTool->saveMetaData($filename, $md5sum, $what); - break; - } } + + $str_columns = implode(', ', $columns); + $str_values = implode(', ', $values); + + /** + * insert empty record even if we have no data to prevent call to this function + * on every image view + */ + $GLOBALS['linpha']->db->Execute("INSERT into ". $db_table . + "(" . $str_columns . ") VALUES (" . $str_values . ")"); + + return $hasData; } /** @@ -1187,7 +1092,239 @@ $image_date = $this->objMetaTool->getDateTimeOriginal($filename); return $image_date; } + + /** + * Define array with allowed IPTC/XMP tags and human readable translation + * This array should correspond with the sql definition in include/sql/sql.tables.php + * @param none + * @return none + * @author bzrudi flo + */ + public static $metaTags = array( + 'xmp' => array( + + //Iptc4xmpCore schema tags + 'countrycode' => 'Country Code', + 'intellectualgenre' => 'Intellectual Genre', + 'location' => 'Location', + 'scene' => 'Scene', + 'subjectcode' => 'Subject Code', + + //Dublin Core schema tags + 'contributor' => 'Contributor', + 'coverage' => 'Coverage', + 'creator' => 'Creator', + 'date' => 'Date', + 'description' => 'Description', + 'format' => 'Format', + 'identifier' => 'Identifier', + 'publisher' => 'Publisher', + 'rights' => 'Rights', + 'subject' => 'Subject', + 'title' => 'Title', + + //Adobe Photoshop schema tags + 'authorsposition' => 'Authors Position', + 'captionwriter' => 'Caption Writer', + 'category' => 'Category', + 'city' => 'City', + 'colormode' => 'Color Mode', + 'country' => 'Country', + 'credit' => 'Credit', + //'datecreated' => 'DateCreated', + 'headline' => 'Headline', + 'iccprofilename' => 'ICC Profile Name', + 'instructions' => 'Instructions', + 'source' => 'Source', + 'state' => 'State', + 'supplementalcategories' => 'Supplemental Categories', + 'transmissionreference' => 'Transmission Reference', + 'urgency' => 'Urgency' + ), + + //IPTC schema tags + 'iptc' => array( + + //IPTC ApplicationRecord Tags + 'applicationrecordversion' => 'Application Record Version', + 'objecttypereference' => 'Object Type Reference', + 'objectattributereference' => 'Object Attribute Reference', + 'objectname' => 'Object Name', + 'objectcycle' => 'Object Cycle', + 'editstatus' => 'Edit Status', + 'subjectreference' => 'Subject Reference', + //'category' => 'Category', + 'supplementalcategories' => 'Supplemental Categories', + 'keywords' => 'Keywords', + 'specialinstructions' => 'Special Instructions', + 'datecreated' => 'Date Created', + 'timecreated' => 'Time Created', + 'by_line' => 'By-line', + 'by_linetitle' => 'By-line Title', + //'city' => 'City', + 'sub_location' => 'Sub-location', + 'province_state' => 'Province-State', + 'country_primarylocationcode' => 'Country-Primary Location Code', + 'country_primarylocationname' => 'Country-Primary Location Name', + 'originaltransmissionreference' => 'Original Transmission Reference', + //'headline' => 'Headline', + //'credit' => 'Credit', + //'source' => 'Source', + 'copyrightnotice' => 'Copyright Notice', + 'contact' => 'Contact', + 'caption_abstract' => 'Caption-Abstract', + 'writer_editor' => 'Writer-Editor', + 'originatingprogram' => 'Originating Program', + 'releasedate' => 'Release Date' + ), + + //EXIF schema tags + 'exif' => array( + + //IFD0 + 'processingsoftware' => 'Processing Software', + 'imagewidth' => 'Image Width', + 'imagelength' => 'Image Length', + 'bitspersample' => 'Bits Per Sample', + 'compression' => 'Compression', + 'photometricinterpretation' => 'Photometric Interpretation', + 'thresholding' => 'Thresholding', + 'cellwidth' => 'Cell Width', + 'celllength' => 'Cell Length', + 'fillorder' => 'Fill Order', + 'documentname' => 'Document Name', + 'imagedescription' => 'Image Description', + 'make' => 'Maker', + 'model' => 'Model', + 'orientation' => 'Orientation', + 'samplesperpixel' => 'Samples Per Pixel', + 'rowsperstrip' => 'Rows Per Strip', + 'minsamplevalue' => 'Min Sample Value', + 'maxsamplevalue' => 'Max Sample Value', + 'xresolution' => 'X Resolution', + 'yresolution' => 'Y Resolution', + 'planarconfiguration' => 'Planar Configuration', + 'pagename' => 'Page Name', + 'xposition' => 'X Position', + 'yposition' => 'Y Position', + 'grayresponseunit' => 'Gray Response Unit', + 'resolutionunit' => 'Resolution Unit', + 'pagenumber' => 'Page Number', + 'software' => 'Software', + 'artist' => 'Artist', + 'hostcomputer' => 'Host Computer', + 'predictor' => 'Predictor', + 'whitepoint' => 'White Point', + 'primarychromaticities' => 'Primary Chromaticities', + 'halftonehints' => 'Halftone Hints', + 'tilewidth' => 'Tile Width', + 'tilelength' => 'Tile Length', + 'ycbcrcoefficients' => 'YCbCr Coefficients', + 'ycbcrsubsampling' => 'YCbCr Sub Sampling', + 'ycbcrpositioning' => 'YCbCr Positioning', + 'referenceblackwhite' => 'Reference Black White', + 'relatedimagefileformat' => 'Related Image File Format', + 'relatedimagewidth' => 'Related Image Width', + 'relatedimagelength' => 'Related Image Length', + 'rating' => 'Rating', + 'ratingpercent' => 'Rating Percent', + 'copyright' => 'Copyright', + + //ExifIFD + 'exposuretime' => 'Exposure Time', + 'fnumber' => 'F Number', + 'exposureprogram' => 'Exposure Program', + 'spectralsensitivity' => 'Spectral Sensitivity', + 'isospeedratings' => 'ISO Speed Ratings', + 'timezoneoffset' => 'Time Zone Offset', + 'selftimermode' => 'Self Timer Mode', + 'exifversion' => 'Exif Version', + 'flashpixversion' => 'FlashPix Version', + 'colorspace' => 'Color Space', + 'pixelxdimension' => 'Pixel X Dimension', + 'pixelydimension' => 'Pixel Y Dimension', + 'datetime' => 'Date Time (Modify Date)', + 'datetimeoriginal' => 'Date Time Original', + 'datetimedigitized' => 'Date Time Digitized (Create Date)', + 'componentsconfiguration' => 'Components Configuration', + 'compressedbitsperpixel' => 'Compressed Bits Per Pixel', + 'shutterspeedvalue' => 'Shutter Speed Value', + 'aperturevalue' => 'Aperture Value', + 'brightnessvalue' => 'Brightness Value', + 'exposurebiasvalue' => 'Exposure Bias Value', + 'exposurecompensation' => 'Exposure Compensation', + 'maxaperturevalue' => 'Max Aperture Value', + 'subjectdistance' => 'Subject Distance', + 'meteringmode' => 'Metering Mode', + 'lightsource' => 'Light Source', + 'flash' => 'Flash', + 'focallength' => 'Focal Length', + 'imagenumber' => 'Image Number', + 'securityclassification' => 'Security Classification', + 'focalplanexresolution' => 'Focal Plane X Resolution', + 'focalplaneyresolution' => 'Foca Plane Y Resolution', + 'focalplaneresolutionunit' => 'Focal Plane Resolution Unit', + 'imagehistory' => 'Image History', + 'subjectlocation' => 'Subject Location', + 'exposureindex' => 'Exposure Index', + 'sensingmethod' => 'Sensing Method', + 'filesource' => 'File Source', + 'scenetype' => 'Scene Type', + 'cfapattern' => 'CFA Pattern', + 'customrendered' => 'Custom Rendered', + 'exposuremode' => 'Exposure Mode', + 'whitebalance' => 'White Balance', + 'digitalzoomratio' => 'Digital Zoom Ratio', + 'focallengthin35mmfilm' => 'Focal Length In 35mm Format', + 'scenecapturetype' => 'Scene Capture Type', + 'gaincontrol' => 'Gain Control', + 'contrast' => 'Contrast', + 'saturation' => 'Saturation', + 'sharpness' => 'Sharpness', + 'subjectdistancerange' => 'Subject Distance Range', + 'gamma' => 'Gamma', + 'relatedsoundfile' => 'Related Sound File', + 'usercomment' => 'User Comment', + 'jpegcomment' => 'JPEG Comment' + ), + + 'exifgps' => array ( + 'gpsversionid' => 'GPS Version ID', + 'gpslatituderef' => 'GPS Latitude Ref', + 'gpslatitude' => 'GPS Latitude', + 'gpslongituderef' => 'GPS Longitude Ref', + 'gpslongitude' => 'GPS Longitude', + 'gpsaltituderef' => 'GPS Altitude Ref', + 'gpsaltitude' => 'GPS Altitude', + 'gpstimestamp' => 'GPS Timestamp', + 'gpssatellites' => 'GPS Satellites', + 'gpsstatus' => 'GPS Status', + 'gpsmeasuremode' => 'GPS Measure Mode', + 'gpsdop' => 'GPS DOP', + 'gpsspeedref' => 'GPS Speed Ref', + 'gpsspeed' => 'GPS Speed', + 'gpstrackref' => 'GPS Track Ref', + 'gpstrack' => 'GPS Track', + 'gpsimgdirectionref' => 'GPS Img Direction Ref', + 'gpsimgdirection' => 'GPS Img Direction', + 'gpsmapdatum' => 'GPS Map Datum', + 'gpsdestlatituderef' => 'GPS Dest Latitude Ref', + 'gpsdestlatitude' => 'GPS Dest Latitude', + 'gpsdestlongituderef' => 'GPS Dest Longitude Ref', + 'gpsdestlongitude' => 'GPS Dest Longitude', + 'gpsdestbearingref' => 'GPS Dest Bearing Ref', + 'gpsdestbearing' => 'GPS Dest Bearing', + 'gpsdestdistanceref' => 'GPS Dest Distance Ref', + 'gpsdestdistance' => 'GPS Dest Distance', + 'gpsprocessingmethod' => 'GPS Processing Method', + 'gpsareainformation' => 'GPS Area Information', + 'gpsdatestamp' => 'GPS DateStamp', + 'gpsdatetime' => 'GPS DateTime', + 'gpsposition' => 'GPS Position', + 'gpsdifferential' => 'GPS Differential' + ) + ); } /* vi: set ts=4 sw=4 sts=4 */ -?> +?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.pjmt.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.pjmt.class.php 2008-04-02 20:54:22 UTC (rev 4915) +++ trunk/linpha2/lib/classes/linpha.pjmt.class.php 2008-04-06 21:38:41 UTC (rev 4916) @@ -34,19 +34,24 @@ */ function __construct() { - } /** - * This method reads all available GeoData Information from image. - * @param string $metatype exi - * @param string $filename - * @return array Array with all available Tag informations - * @author bzrudi - * @todo respect exec return status, don't use filename as input (security) + * This method reads all available exif/gps/iptc/xmp information from image. + * @param string $filename filename to parse for MetaData + * @param string $md5sum md5sum of file + * @param string $tag save IPTC or XMP MetaData */ public function readMetaDataFromFile($metatype, $filename) { + $metaArray = array(); + + if (!isset(LinPjmtTool::$metaTags[$metatype])) + { + // TODO IPTC and XMP currently not implemented + return $metaArray; + } + include_once (LINPHA_DIR . '/lib/pjmt/JPEG.php'); include_once (LINPHA_DIR . '/lib/pjmt/EXIF.php'); @@ -54,165 +59,89 @@ * get exif info from file */ $exif_data = get_EXIF_JPEG($filename); - - if($exif_data) + if (!$exif_data) { - /** - * search for valid tags - */ - foreach($this->getDefaultMetaTags('gps') AS $key => $value) + return $metaArray(); + } + + /** + * special tags + */ + // Canon Owner Name append to Artist + if (isset($exif_data['Makernote_Tag']['Decoded Data']) + && is_array($exif_data['Makernote_Tag']['Decoded Data']) // sometimes 'Decoded Data' is an empty string + && isset($exif_data['Makernote_Tag']['Decoded Data'][0][9]['Text Value'])) + { + $owner = $exif_data['Makernote_Tag']['Decoded Data'][0][9]['Text Value']; + if (isset($exif_data[0][315]['Text Value'])) { - if(!empty(LinPjmtTool::$metaTags['exif'][$value]['pathvalue'])) - { - /** - * there are currently only entries at level deep 2 and 5 - * in the array - */ - $ap = explode('/', - LinPjmtTool::$metaTags['exif'][$value]['pathvalue']); - - switch(count($ap)) - { - case 2 : - if(isset($exif_data[$ap[0]][$ap[1]]['Text Value'])) - { - //echo "DATA:".$exif_data[$ap[0]][$ap[1]]['Text Value']."<br>"; - $dataArray[$value] = - LinSql::linAddslashes(trim($exif_data[$ap[0]][$ap[1]]['Text Value'])); - } - break; - case 5 : - if(isset($exif_data[$ap[0]][$ap[1]][$ap[2]][$ap[3]][$ap[4]]['Text Value'])) - { - //echo "DATA2".$exif_data... [truncated message content] |