Ignore:
Timestamp:
Jul 29, 2010, 10:12:25 AM (14 years ago)
Author:
grum
Message:

feature:1777

  • Weight of the metadata database can becomes very heavy
Location:
extensions/AMetaData/JpegMetaData
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • extensions/AMetaData/JpegMetaData/Common/Const.class.php

    r4686 r6729  
    142142  }
    143143
     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
    144156?>
  • extensions/AMetaData/JpegMetaData/Common/Tag.class.php

    r4904 r6729  
    4545 *  - tagValue          : the 'raw' value of the tag, not interpreted ; can be
    4646 *                        of any type
    47  *  - valuelabel        : the interpreted value of the tag ; in most case it's a
     47 *  - valueLabel        : the interpreted value of the tag ; in most case it's a
    4848 *                        String, but can be an Integer, a Float or an Array
    4949 *  - tagIsKnown        : indicates if the tag is a known tag or not
     
    5252 *  - tagIsTranslatable : indicates if the interpreted value for the tag is
    5353 *                        translatable
     54 *  - schema            : the schema associated with the tag ('exif', 'iptc', 'xmp', 'magic')
    5455 *
    5556 * This class provides theses public functions :
     
    5960 *  - getLabel
    6061 *  - getNote
     62 *  - getSchema
    6163 *  - isKnown
    6264 *  - isImplemented
     
    6769 *  - setLabel
    6870 *  - setNote
     71 *  - setSchema
    6972 *  - setKnown
    7073 *  - setImplemented
     
    8487    private $tagIsImplemented = false;
    8588    private $tagIsTranslatable = false;
     89    private $tagSchema = "";
    8690
    8791    /**
     
    104108     * @param Boolean $tagIstranslatable (optional) : determine if the tag value
    105109     *                                                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="")
    109114    {
    110115      $this->tagId = $tagId;
     
    116121      $this->tagIsImplemented=$tagIsImplemented;
    117122      $this->tagIsTranslatable=$tagIsTranslatable;
     123      $this->tagSchema = $schema;
    118124    }
    119125
     
    128134      unset($this->tagIsImplemented);
    129135      unset($this->tagIsTranslatable);
     136      unset($this->tagSchema);
    130137    }
    131138
     
    202209
    203210    /**
     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    /**
    204221     * returns true if the tag value can be translated
    205222     *
     
    296313
    297314    /**
     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    /**
    298328     * set if the tag value is translatable
    299329     *
     
    313343      if($mode=="all")
    314344        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))." ; ";
    316347        else
    317348          $returned.="tag: 0x".sprintf("%04x", $this->tagId)." ; ";
  • extensions/AMetaData/JpegMetaData/JpegMetaData.class.php

    r6722 r6729  
    44 *
    55 * Version : 1.0.1
    6  * Date    : 2010-07-24
     6 * Date    : 2010-07-29
    77 *
    88 *  Author    : Grum
     
    4141 * | 1.0.0   |            | * first public release
    4242 * |         |            |
    43  * | 1.0.1   | 2010-07-24 | * mantis bug:1686
     43 * | 1.0.1   | 2010-07-29 | * mantis bug:1686
    4444 * |         |            |   . bug reported on IfdReader
    4545 * |         |            |     When sub IFD (0x8769) refers to a sub IFD with
     
    5050 * |         |            |     (right solution: to be able to read negative
    5151 * |         |            |     offset)
     52 * |         |            |
    5253 * |         |            | * mantis feature : 1719
    5354 * |         |            |   . Coding a DateTime class ; used only if there is
    5455 * |         |            |     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 * |         |            |
    5567 * |         |            |
    5668 * |         |            |
     
    133145    const TAGFILTER_IMPLEMENTED = 0x02;
    134146    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";
    143147
    144148    private $jpeg = null;
     
    238242          case "exif":
    239243            $tmp=new IfdTags();
    240             $schema="exif";
     244            $schema=Schemas::EXIF;
    241245            break;
    242246          case "gps":
    243247            $tmp=new GpsTags();
    244             $schema="exif.gps";
     248            $schema=Schemas::EXIF_GPS;
    245249            break;
    246250          case "iptc":
    247251            $tmp=new IptcTags();
    248             $schema="iptc";
     252            $schema=Schemas::IPTC;
    249253            break;
    250254          case "xmp":
    251255            $tmp=new XmpTags();
    252             $schema="xmp";
     256            $schema=Schemas::XMP;
    253257            break;
    254258          case "magic":
    255259            $tmp=new MagicTags();
    256             $schema="magic";
     260            $schema=Schemas::MAGIC;
    257261            break;
    258262          case MAKER_PENTAX:
    259263            include_once(JPEG_METADATA_DIR."TagDefinitions/PentaxTags.class.php");
    260264            $tmp=new PentaxTags();
    261             $schema="exif.".MAKER_PENTAX;
     265            $schema=Schemas::EXIF_MAKER.'.'.MAKER_PENTAX;
    262266            break;
    263267          case MAKER_NIKON:
    264268            include_once(JPEG_METADATA_DIR."TagDefinitions/NikonTags.class.php");
    265269            $tmp=new NikonTags();
    266             $schema="exif.".MAKER_NIKON;
     270            $schema=Schemas::EXIF_MAKER.'.'.MAKER_NIKON;
    267271            break;
    268272          case MAKER_CANON:
    269273            include_once(JPEG_METADATA_DIR."TagDefinitions/CanonTags.class.php");
    270274            $tmp=new CanonTags();
    271             $schema="exif.".MAKER_CANON;
     275            $schema=Schemas::EXIF_MAKER.'.'.MAKER_CANON;
    272276            break;
    273277          default:
     
    287291                $name=$key;
    288292
    289               if(array_key_exists('schema', $tag) and $val=="exif")
     293              if(array_key_exists('schema', $tag) and $val==Schemas::EXIF)
    290294                $subSchema=".".$tag['schema'];
    291295              else
    292296                $subSchema="";
    293297
    294               if($val=='xmp')
     298              if($val==Schemas::XMP)
    295299                $keyName=$schema.$subSchema.".".$key;
    296300              else
     
    405409               * Load Exifs tags from Tiff block
    406410               */
    407               if($data->getNbIFDs()>0)
     411              if($data->getNbIFDs()>0 and
     412                 ($this->options['magic'] or $this->options['exif'] or $this->options['maker']))
    408413              {
    409                 $this->loadIfdTags($data->getIFD(0), self::KEY_EXIF_TIFF);
     414                $this->loadIfdTags($data->getIFD(0), Schemas::EXIF_TIFF);
    410415              }
    411416            }
     
    415420               * Load Xmp tags from Xmp block
    416421               */
    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              }
    418426            }
    419427            elseif($data instanceof IptcReader)
     
    425433                $data->optimizeDateTime();
    426434
    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              }
    428439            }
    429440          }
     
    433444        {
    434445          $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]);
    435452        }
    436453
     
    543560            {
    544561              case 'Exif IFD Pointer':
    545                 $exifKey2=self::KEY_EXIF_EXIF;
     562                $exifKey2=Schemas::EXIF_EXIF;
    546563                break;
    547564              case 'MakerNote':
    548                 $exifKey2=self::KEY_EXIF.".".$tag->getTag()->getLabel()->getMaker();
     565                $exifKey2=Schemas::EXIF_MAKER.".".$tag->getTag()->getLabel()->getMaker();
    549566                break;
    550567              case 'GPS IFD Pointer':
    551                 $exifKey2=self::KEY_EXIF_GPS;
     568                $exifKey2=Schemas::EXIF_GPS;
    552569                break;
    553570              default:
     
    621638            $tag->setImplemented($val['implemented']);
    622639            $tag->setTranslatable($val['translatable']);
     640            $tag->setSchema(Schemas::MAGIC);
    623641
    624642            $i=count($val['tagValues']);
  • extensions/AMetaData/JpegMetaData/Readers/CanonReader.class.php

    r5222 r6729  
    5656  class CanonReader extends MakerNotesReader
    5757  {
     58    protected $schema = Schemas::EXIF;
     59
    5860    /**
    5961     * The constructor needs, like the ancestor, the datas to be parsed
     
    187189          $entry->getTag()->setImplemented($tagDef['implemented']);
    188190          $entry->getTag()->setTranslatable($tagDef['translatable']);
     191          $entry->getTag()->setSchema($this->schema);
    189192
    190193          if(array_key_exists('tagValues', $tagDef))
     
    333336          $entry->getTag()->setImplemented($tagDef['implemented']);
    334337          $entry->getTag()->setTranslatable($tagDef['translatable']);
     338          $entry->getTag()->setSchema($this->schema);
    335339
    336340          if(array_key_exists('tagValues', $tagDef))
     
    509513          $entry->getTag()->setImplemented($subTagDef['implemented']);
    510514          $entry->getTag()->setTranslatable($subTagDef['translatable']);
     515          $entry->getTag()->setSchema($this->schema);
    511516
    512517          if(array_key_exists('tagValues', $subTagDef))
     
    598603          $entry->getTag()->setImplemented($subTagDef['implemented']);
    599604          $entry->getTag()->setTranslatable($subTagDef['translatable']);
     605          $entry->getTag()->setSchema($this->schema);
    600606
    601607          if(array_key_exists('tagValues', $subTagDef))
  • extensions/AMetaData/JpegMetaData/Readers/GpsReader.class.php

    r5222 r6729  
    5454  class GpsReader extends IfdReader
    5555  {
     56    protected $schema = Schemas::EXIF;
     57
    5658    function __destruct()
    5759    {
  • extensions/AMetaData/JpegMetaData/Readers/IfdReader.class.php

    r6722 r6729  
    8181  {
    8282    protected $byteOrder = BYTE_ORDER_LITTLE_ENDIAN;
     83    protected $schema = Schemas::EXIF;
     84
    8385
    8486    private $nextIFDOffset = 0;
    8587
    8688    private $dataOffset = 0;
     89
    8790
    8891    /**
     
    233236        $entry->getTag()->setImplemented($tag['implemented']);
    234237        $entry->getTag()->setTranslatable($tag['translatable']);
     238        $entry->getTag()->setSchema($this->schema);
    235239
    236240        /*
  • extensions/AMetaData/JpegMetaData/Readers/IptcReader.class.php

    r5237 r6729  
    6565    const HEADER_1 = "Photoshop 3.0\x00";
    6666    const HEADER_2 = "Adobe_Photoshop2.5:\x00";
     67    protected $schema = Schemas::IPTC;
    6768
    6869    private $header = "";
     
    237238        $tag->setImplemented($tagProperties['implemented']);
    238239        $tag->setTranslatable($tagProperties['translatable']);
     240        $tag->setSchema($this->schema);
    239241
    240242        /*
  • extensions/AMetaData/JpegMetaData/Readers/NikonReader.class.php

    r5228 r6729  
    5959  class NikonReader extends MakerNotesReader
    6060  {
     61    protected $schema = Schemas::EXIF;
     62
    6163    /* these 2 specific metadata are used to decrypt some information, like the
    6264     * data lens
  • extensions/AMetaData/JpegMetaData/Readers/PentaxReader.class.php

    r5222 r6729  
    6060  class PentaxReader extends MakerNotesReader
    6161  {
     62    protected $schema = Schemas::EXIF;
     63
    6264    /**
    6365     * The constructor needs, like the ancestor, the datas to be parsed
  • extensions/AMetaData/JpegMetaData/Readers/XmpReader.class.php

    r5237 r6729  
    5353  class XmpReader extends GenericReader
    5454  {
     55    protected $schema = Schemas::XMP;
     56
    5557    private $xmlData = NULL;
    5658
     
    300302        $tag->setImplemented($tagProperties['implemented']);
    301303        $tag->setTranslatable($tagProperties['translatable']);
    302 
     304        $tag->setSchema($this->schema);
    303305
    304306        if(array_key_exists('name', $tagProperties))
Note: See TracChangeset for help on using the changeset viewer.