From: Ævar Arnfjörð Bjarmason Date: Sun, 17 Jul 2005 19:22:15 +0000 (+0000) Subject: * Moved some code into the Exif and FormatExif classes X-Git-Tag: 1.5.0beta4~108 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=90da6ca44cc5693fb1d040793463d9a94dd29ef5;p=lhc%2Fweb%2Fwiklou.git * Moved some code into the Exif and FormatExif classes --- diff --git a/includes/Image.php b/includes/Image.php index 75d85906b7..e9f2f418ff 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -48,7 +48,6 @@ class Image $mime, # MIME type, determined by MimeMagic::guessMimeType $size, # Size in bytes (loadFromXxx) $metadata, # Metadata - $exif, # The Exif class $dataLoaded; # Whether or not all this has been loaded from the database (loadFromXxx) @@ -87,9 +86,6 @@ class Image $this->historyLine = 0; $this->dataLoaded = false; - - if ($wgShowEXIF) - $this->exif = new Exif; } /** @@ -1419,24 +1415,8 @@ class Image function retrieveExifData () { if ( $this->getMimeType() !== "image/jpeg" ) return array (); - wfSuppressWarnings(); - $exif = exif_read_data( $this->imagePath ); - wfRestoreWarnings(); - - foreach($exif as $k => $v) { - if ( !in_array($k, array_keys($this->exif->mFlatExif)) ) { - wfDebug( "Image::retrieveExifData: '$k' is not a valid Exif tag (type: '" . gettype($v) . "'; data: '$v')\n"); - unset($exif[$k]); - } - } - - foreach($exif as $k => $v) { - if ( !$this->exif->validate($k, $v) ) { - wfDebug( "Image::retrieveExifData: '$k' contained invalid data (type: '" . gettype($v) . "'; data: '$v')\n"); - unset($exif[$k]); - } - } - return $exif; + $exif = new Exif( $this->imagePath ); + return $exif->getFilteredData(); } function getExifData () { @@ -1448,19 +1428,15 @@ class Image $ret = unserialize ( $this->metadata ); $oldver = isset( $ret['MEDIAWIKI_EXIF_VERSION'] ) ? $ret['MEDIAWIKI_EXIF_VERSION'] : 0; - $newver = $this->exif->version(); + $newver = Exif::version(); if ( !count( $ret ) || $purge || $oldver != $newver ) { $this->updateExifData( $newver ); } if ( isset( $ret['MEDIAWIKI_EXIF_VERSION'] ) ) unset( $ret['MEDIAWIKI_EXIF_VERSION'] ); - - foreach($ret as $k => $v) { - $ret[$k] = $this->exif->format($k, $v); - } - - return $ret; + $format = new FormatExif( $ret ); + return $format->getFormattedData(); } function updateExifData( $version ) {