Changeset 6729 for extensions/AMetaData/JpegMetaData
- Timestamp:
- Jul 29, 2010, 10:12:25 AM (14 years ago)
- Location:
- extensions/AMetaData/JpegMetaData
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/AMetaData/JpegMetaData/Common/Const.class.php
r4686 r6729 142 142 } 143 143 144 class Schemas { 145 const EXIF = "exif"; 146 const IPTC = "iptc"; 147 const XMP = "xmp"; 148 const MAGIC = "magic"; 149 150 const EXIF_TIFF = "exif.tiff"; 151 const EXIF_EXIF = "exif.exif"; 152 const EXIF_GPS = "exif.gps"; 153 const EXIF_MAKER = "exif.maker"; 154 } 155 144 156 ?> -
extensions/AMetaData/JpegMetaData/Common/Tag.class.php
r4904 r6729 45 45 * - tagValue : the 'raw' value of the tag, not interpreted ; can be 46 46 * of any type 47 * - value label : the interpreted value of the tag ; in most case it's a47 * - valueLabel : the interpreted value of the tag ; in most case it's a 48 48 * String, but can be an Integer, a Float or an Array 49 49 * - tagIsKnown : indicates if the tag is a known tag or not … … 52 52 * - tagIsTranslatable : indicates if the interpreted value for the tag is 53 53 * translatable 54 * - schema : the schema associated with the tag ('exif', 'iptc', 'xmp', 'magic') 54 55 * 55 56 * This class provides theses public functions : … … 59 60 * - getLabel 60 61 * - getNote 62 * - getSchema 61 63 * - isKnown 62 64 * - isImplemented … … 67 69 * - setLabel 68 70 * - setNote 71 * - setSchema 69 72 * - setKnown 70 73 * - setImplemented … … 84 87 private $tagIsImplemented = false; 85 88 private $tagIsTranslatable = false; 89 private $tagSchema = ""; 86 90 87 91 /** … … 104 108 * @param Boolean $tagIstranslatable (optional) : determine if the tag value 105 109 * can be translated or not 106 * 107 */ 108 function __construct($tagId=0xffff, $tagValue=0, $tagName="", $valueLabel="", $tagNote="", $tagIsKnown=false, $tagIsImplemented=false, $tagIsTranslatable=false) 110 * @param String $schema (optional) : schema associated with to 111 * the tag 112 */ 113 function __construct($tagId=0xffff, $tagValue=0, $tagName="", $valueLabel="", $tagNote="", $tagIsKnown=false, $tagIsImplemented=false, $tagIsTranslatable=false, $schema="") 109 114 { 110 115 $this->tagId = $tagId; … … 116 121 $this->tagIsImplemented=$tagIsImplemented; 117 122 $this->tagIsTranslatable=$tagIsTranslatable; 123 $this->tagSchema = $schema; 118 124 } 119 125 … … 128 134 unset($this->tagIsImplemented); 129 135 unset($this->tagIsTranslatable); 136 unset($this->tagSchema); 130 137 } 131 138 … … 202 209 203 210 /** 211 * returns the schema associated to the tag 212 * 213 * @return String 214 */ 215 public function getSchema() 216 { 217 return($this->tagSchema); 218 } 219 220 /** 204 221 * returns true if the tag value can be translated 205 222 * … … 296 313 297 314 /** 315 * set a schema to the tag 316 * 317 * @param String $value 318 * @return String 319 */ 320 public function setSchema($value) 321 { 322 $this->tagSchema=$value; 323 return($this->tagSchema); 324 } 325 326 327 /** 298 328 * set if the tag value is translatable 299 329 * … … 313 343 if($mode=="all") 314 344 if(is_string($this->tagId)) 315 $returned.="tag: ".str_replace(" ", " ", sprintf("%-34s", $this->tagId))." ; "; 345 $returned.="tag: ".str_replace(" ", " ", sprintf("%-34s", $this->tagId))." ; 346 schema: ".str_replace(" ", " ", sprintf("%-5s", $this->tagSchema))." ; "; 316 347 else 317 348 $returned.="tag: 0x".sprintf("%04x", $this->tagId)." ; "; -
extensions/AMetaData/JpegMetaData/JpegMetaData.class.php
r6722 r6729 4 4 * 5 5 * Version : 1.0.1 6 * Date : 2010-07-2 46 * Date : 2010-07-29 7 7 * 8 8 * Author : Grum … … 41 41 * | 1.0.0 | | * first public release 42 42 * | | | 43 * | 1.0.1 | 2010-07-2 4| * mantis bug:168643 * | 1.0.1 | 2010-07-29 | * mantis bug:1686 44 44 * | | | . bug reported on IfdReader 45 45 * | | | When sub IFD (0x8769) refers to a sub IFD with … … 50 50 * | | | (right solution: to be able to read negative 51 51 * | | | offset) 52 * | | | 52 53 * | | | * mantis feature : 1719 53 54 * | | | . Coding a DateTime class ; used only if there is 54 55 * | | | no PHP built-in DateTime class 56 * | | | 57 * | | | * add the "schema" property to Tag class 58 * | | | 59 * | | | * fixed bug about filtering schema 60 * | | | . when loading metadata, filter on schema are now 61 * | | | applied ; 'magic' metadata are computed even if 62 * | | | the other schema are filtered 63 * | | | 64 * | | | 65 * | | | 66 * | | | 55 67 * | | | 56 68 * | | | … … 133 145 const TAGFILTER_IMPLEMENTED = 0x02; 134 146 const TAGFILTER_ALL = 0x03; 135 136 const KEY_EXIF_TIFF = "exif.tiff";137 const KEY_EXIF_EXIF = "exif.exif";138 const KEY_EXIF_GPS = "exif.gps";139 const KEY_EXIF = "exif";140 const KEY_IPTC = "iptc";141 const KEY_XMP = "xmp";142 const KEY_MAGIC = "magic";143 147 144 148 private $jpeg = null; … … 238 242 case "exif": 239 243 $tmp=new IfdTags(); 240 $schema= "exif";244 $schema=Schemas::EXIF; 241 245 break; 242 246 case "gps": 243 247 $tmp=new GpsTags(); 244 $schema= "exif.gps";248 $schema=Schemas::EXIF_GPS; 245 249 break; 246 250 case "iptc": 247 251 $tmp=new IptcTags(); 248 $schema= "iptc";252 $schema=Schemas::IPTC; 249 253 break; 250 254 case "xmp": 251 255 $tmp=new XmpTags(); 252 $schema= "xmp";256 $schema=Schemas::XMP; 253 257 break; 254 258 case "magic": 255 259 $tmp=new MagicTags(); 256 $schema= "magic";260 $schema=Schemas::MAGIC; 257 261 break; 258 262 case MAKER_PENTAX: 259 263 include_once(JPEG_METADATA_DIR."TagDefinitions/PentaxTags.class.php"); 260 264 $tmp=new PentaxTags(); 261 $schema= "exif.".MAKER_PENTAX;265 $schema=Schemas::EXIF_MAKER.'.'.MAKER_PENTAX; 262 266 break; 263 267 case MAKER_NIKON: 264 268 include_once(JPEG_METADATA_DIR."TagDefinitions/NikonTags.class.php"); 265 269 $tmp=new NikonTags(); 266 $schema= "exif.".MAKER_NIKON;270 $schema=Schemas::EXIF_MAKER.'.'.MAKER_NIKON; 267 271 break; 268 272 case MAKER_CANON: 269 273 include_once(JPEG_METADATA_DIR."TagDefinitions/CanonTags.class.php"); 270 274 $tmp=new CanonTags(); 271 $schema= "exif.".MAKER_CANON;275 $schema=Schemas::EXIF_MAKER.'.'.MAKER_CANON; 272 276 break; 273 277 default: … … 287 291 $name=$key; 288 292 289 if(array_key_exists('schema', $tag) and $val== "exif")293 if(array_key_exists('schema', $tag) and $val==Schemas::EXIF) 290 294 $subSchema=".".$tag['schema']; 291 295 else 292 296 $subSchema=""; 293 297 294 if($val== 'xmp')298 if($val==Schemas::XMP) 295 299 $keyName=$schema.$subSchema.".".$key; 296 300 else … … 405 409 * Load Exifs tags from Tiff block 406 410 */ 407 if($data->getNbIFDs()>0) 411 if($data->getNbIFDs()>0 and 412 ($this->options['magic'] or $this->options['exif'] or $this->options['maker'])) 408 413 { 409 $this->loadIfdTags($data->getIFD(0), self::KEY_EXIF_TIFF);414 $this->loadIfdTags($data->getIFD(0), Schemas::EXIF_TIFF); 410 415 } 411 416 } … … 415 420 * Load Xmp tags from Xmp block 416 421 */ 417 $this->loadTags($data->getTags(), self::KEY_XMP); 422 if($this->options['magic'] or $this->options['xmp']) 423 { 424 $this->loadTags($data->getTags(), Schemas::XMP); 425 } 418 426 } 419 427 elseif($data instanceof IptcReader) … … 425 433 $data->optimizeDateTime(); 426 434 427 $this->loadTags($data->getTags(), self::KEY_IPTC); 435 if($this->options['magic'] or $this->options['iptc']) 436 { 437 $this->loadTags($data->getTags(), Schemas::IPTC); 438 } 428 439 } 429 440 } … … 433 444 { 434 445 $this->processMagicTags(); 446 } 447 448 // clean all unwanted metadata 449 foreach($this->tags as $key => $tag) 450 { 451 if(!$this->options[$tag->getSchema()]) unset($this->tags[$key]); 435 452 } 436 453 … … 543 560 { 544 561 case 'Exif IFD Pointer': 545 $exifKey2= self::KEY_EXIF_EXIF;562 $exifKey2=Schemas::EXIF_EXIF; 546 563 break; 547 564 case 'MakerNote': 548 $exifKey2= self::KEY_EXIF.".".$tag->getTag()->getLabel()->getMaker();565 $exifKey2=Schemas::EXIF_MAKER.".".$tag->getTag()->getLabel()->getMaker(); 549 566 break; 550 567 case 'GPS IFD Pointer': 551 $exifKey2= self::KEY_EXIF_GPS;568 $exifKey2=Schemas::EXIF_GPS; 552 569 break; 553 570 default: … … 621 638 $tag->setImplemented($val['implemented']); 622 639 $tag->setTranslatable($val['translatable']); 640 $tag->setSchema(Schemas::MAGIC); 623 641 624 642 $i=count($val['tagValues']); -
extensions/AMetaData/JpegMetaData/Readers/CanonReader.class.php
r5222 r6729 56 56 class CanonReader extends MakerNotesReader 57 57 { 58 protected $schema = Schemas::EXIF; 59 58 60 /** 59 61 * The constructor needs, like the ancestor, the datas to be parsed … … 187 189 $entry->getTag()->setImplemented($tagDef['implemented']); 188 190 $entry->getTag()->setTranslatable($tagDef['translatable']); 191 $entry->getTag()->setSchema($this->schema); 189 192 190 193 if(array_key_exists('tagValues', $tagDef)) … … 333 336 $entry->getTag()->setImplemented($tagDef['implemented']); 334 337 $entry->getTag()->setTranslatable($tagDef['translatable']); 338 $entry->getTag()->setSchema($this->schema); 335 339 336 340 if(array_key_exists('tagValues', $tagDef)) … … 509 513 $entry->getTag()->setImplemented($subTagDef['implemented']); 510 514 $entry->getTag()->setTranslatable($subTagDef['translatable']); 515 $entry->getTag()->setSchema($this->schema); 511 516 512 517 if(array_key_exists('tagValues', $subTagDef)) … … 598 603 $entry->getTag()->setImplemented($subTagDef['implemented']); 599 604 $entry->getTag()->setTranslatable($subTagDef['translatable']); 605 $entry->getTag()->setSchema($this->schema); 600 606 601 607 if(array_key_exists('tagValues', $subTagDef)) -
extensions/AMetaData/JpegMetaData/Readers/GpsReader.class.php
r5222 r6729 54 54 class GpsReader extends IfdReader 55 55 { 56 protected $schema = Schemas::EXIF; 57 56 58 function __destruct() 57 59 { -
extensions/AMetaData/JpegMetaData/Readers/IfdReader.class.php
r6722 r6729 81 81 { 82 82 protected $byteOrder = BYTE_ORDER_LITTLE_ENDIAN; 83 protected $schema = Schemas::EXIF; 84 83 85 84 86 private $nextIFDOffset = 0; 85 87 86 88 private $dataOffset = 0; 89 87 90 88 91 /** … … 233 236 $entry->getTag()->setImplemented($tag['implemented']); 234 237 $entry->getTag()->setTranslatable($tag['translatable']); 238 $entry->getTag()->setSchema($this->schema); 235 239 236 240 /* -
extensions/AMetaData/JpegMetaData/Readers/IptcReader.class.php
r5237 r6729 65 65 const HEADER_1 = "Photoshop 3.0\x00"; 66 66 const HEADER_2 = "Adobe_Photoshop2.5:\x00"; 67 protected $schema = Schemas::IPTC; 67 68 68 69 private $header = ""; … … 237 238 $tag->setImplemented($tagProperties['implemented']); 238 239 $tag->setTranslatable($tagProperties['translatable']); 240 $tag->setSchema($this->schema); 239 241 240 242 /* -
extensions/AMetaData/JpegMetaData/Readers/NikonReader.class.php
r5228 r6729 59 59 class NikonReader extends MakerNotesReader 60 60 { 61 protected $schema = Schemas::EXIF; 62 61 63 /* these 2 specific metadata are used to decrypt some information, like the 62 64 * data lens -
extensions/AMetaData/JpegMetaData/Readers/PentaxReader.class.php
r5222 r6729 60 60 class PentaxReader extends MakerNotesReader 61 61 { 62 protected $schema = Schemas::EXIF; 63 62 64 /** 63 65 * The constructor needs, like the ancestor, the datas to be parsed -
extensions/AMetaData/JpegMetaData/Readers/XmpReader.class.php
r5237 r6729 53 53 class XmpReader extends GenericReader 54 54 { 55 protected $schema = Schemas::XMP; 56 55 57 private $xmlData = NULL; 56 58 … … 300 302 $tag->setImplemented($tagProperties['implemented']); 301 303 $tag->setTranslatable($tagProperties['translatable']); 302 304 $tag->setSchema($this->schema); 303 305 304 306 if(array_key_exists('name', $tagProperties))
Note: See TracChangeset
for help on using the changeset viewer.