- Timestamp:
- Sep 27, 2004, 11:51:07 PM (20 years ago)
- Location:
- trunk/admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/create_listing_file.php
r526 r538 38 38 'avi','mp3','ogg'); 39 39 40 // $conf['picture_ext'] must be a subset of $conf['file_ext']40 // $conf['picture_ext'] must be a subset of $conf['file_ext'] 41 41 $conf['picture_ext'] = array('jpg','JPG','png','PNG','gif','GIF'); 42 42 … … 45 45 $conf['version'] = 'BSF'; 46 46 47 // $conf['use_exif'] set to true if you want to use Exif Date as "creation 48 // date" for the element, otherwise, set to false 49 $conf['use_exif'] = true; 50 51 // $conf['use_iptc'] set to true if you want to use IPTC informations of the 52 // element according to get_sync_iptc_data function mapping, otherwise, set 53 // to false 54 $conf['use_iptc'] = false; 55 47 56 // +-----------------------------------------------------------------------+ 48 57 // | functions | 49 58 // +-----------------------------------------------------------------------+ 59 60 /** 61 * returns informations from IPTC metadata, mapping is done at the beginning 62 * of the function 63 * 64 * @param string $filename 65 * @return array 66 */ 67 function get_iptc_data($filename, $map) 68 { 69 $result = array(); 70 71 // Read IPTC data 72 $iptc = array(); 73 74 $imginfo = array(); 75 getimagesize($filename, $imginfo); 76 77 if (isset($imginfo['APP13'])) 78 { 79 $iptc = iptcparse($imginfo['APP13']); 80 if (is_array($iptc)) 81 { 82 $rmap = array_flip($map); 83 foreach (array_keys($rmap) as $iptc_key) 84 { 85 if (isset($iptc[$iptc_key][0]) and $value = $iptc[$iptc_key][0]) 86 { 87 // strip leading zeros (weird Kodak Scanner software) 88 while ($value[0] == chr(0)) 89 { 90 $value = substr($value, 1); 91 } 92 // remove binary nulls 93 $value = str_replace(chr(0x00), ' ', $value); 94 95 foreach (array_keys($map, $iptc_key) as $pwg_key) 96 { 97 $result[$pwg_key] = $value; 98 } 99 } 100 } 101 } 102 } 103 return $result; 104 } 105 106 function get_sync_iptc_data($file) 107 { 108 $map = array( 109 'keywords' => '2#025', 110 'date_creation' => '2#055', 111 'author' => '2#122', 112 'name' => '2#085', 113 'comment' => '2#120' 114 ); 115 $datefields = array('date_creation', 'date_available'); 116 117 $iptc = get_iptc_data($file, $map); 118 119 foreach ($iptc as $pwg_key => $value) 120 { 121 if (in_array($pwg_key, $datefields)) 122 { 123 if ( preg_match('/(\d{4})(\d{2})(\d{2})/', $value, $matches)) 124 { 125 $iptc[$pwg_key] = $matches[1].'-'.$matches[2].'-'.$matches[3]; 126 } 127 } 128 } 129 130 return $iptc; 131 } 50 132 51 133 /** … … 265 347 $element['height'] = $image_size[1]; 266 348 } 349 350 if ($conf['use_exif']) 351 { 352 if ($exif = @read_exif_data($dir.'/'.$fs_file)) 353 { 354 if (isset($exif['DateTime'])) 355 { 356 preg_match('/^(\d{4}):(\d{2}):(\d{2})/' 357 ,$exif['DateTime'] 358 ,$matches); 359 $element['date_creation'] = 360 $matches[1].'-'.$matches[2].'-'.$matches[3]; 361 } 362 } 363 } 364 365 if ($conf['use_iptc']) 366 { 367 $iptc = get_sync_iptc_data($dir.'/'.$fs_file); 368 if (count($iptc) > 0) 369 { 370 foreach (array_keys($iptc) as $key) 371 { 372 $element[$key] = addslashes($iptc[$key]); 373 } 374 } 375 } 267 376 268 377 array_push($elements, $element); … … 300 409 $xml = "\n".$indent.'<root>'; 301 410 $attributes = array('file','tn_ext','representative_ext','filesize', 302 'width','height'); 411 'width','height','date_creation','author','keywords', 412 'name','comment'); 303 413 foreach ($elements as $element) 304 414 { -
trunk/admin/remote_site.php
r534 r538 414 414 'filesize', 415 415 'width', 416 'height'); 416 'height', 417 'date_creation', 418 'author', 419 'keywords', 420 'name', 421 'comment'); 417 422 foreach ($optional_atts as $att) 418 423 { … … 429 434 { 430 435 $dbfields = array('file','storage_category_id','date_available','tn_ext', 431 'filesize','width','height'); 436 'filesize','width','height','date_creation','author', 437 'keywords','name','comment'); 432 438 mass_inserts(IMAGES_TABLE, $dbfields, $inserts); 433 439 $counts{'new_elements'}+= count($inserts);
Note: See TracChangeset
for help on using the changeset viewer.