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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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']);
Note: See TracChangeset for help on using the changeset viewer.