summaryrefslogtreecommitdiff
path: root/includes/media/PNG.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/media/PNG.php')
-rw-r--r--includes/media/PNG.php50
1 files changed, 36 insertions, 14 deletions
diff --git a/includes/media/PNG.php b/includes/media/PNG.php
index 98f13861..7b3ddb51 100644
--- a/includes/media/PNG.php
+++ b/includes/media/PNG.php
@@ -27,7 +27,6 @@
* @ingroup Media
*/
class PNGHandler extends BitmapHandler {
-
const BROKEN_FILE = '0';
/**
@@ -41,6 +40,7 @@ class PNGHandler extends BitmapHandler {
} catch ( Exception $e ) {
// Broken file?
wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
+
return self::BROKEN_FILE;
}
@@ -48,28 +48,41 @@ class PNGHandler extends BitmapHandler {
}
/**
- * @param $image File
+ * @param File $image
* @return array|bool
*/
function formatMetadata( $image ) {
+ $meta = $this->getCommonMetaArray( $image );
+ if ( count( $meta ) === 0 ) {
+ return false;
+ }
+
+ return $this->formatMetadataHelper( $meta );
+ }
+
+ /**
+ * Get a file type independent array of metadata.
+ *
+ * @param File $image
+ * @return array The metadata array
+ */
+ public function getCommonMetaArray( File $image ) {
$meta = $image->getMetadata();
if ( !$meta ) {
- return false;
+ return array();
}
$meta = unserialize( $meta );
- if ( !isset( $meta['metadata'] ) || count( $meta['metadata'] ) <= 1 ) {
- return false;
+ if ( !isset( $meta['metadata'] ) ) {
+ return array();
}
+ unset( $meta['metadata']['_MW_PNG_VERSION'] );
- if ( isset( $meta['metadata']['_MW_PNG_VERSION'] ) ) {
- unset( $meta['metadata']['_MW_PNG_VERSION'] );
- }
- return $this->formatMetadataHelper( $meta['metadata'] );
+ return $meta['metadata'];
}
/**
- * @param $image File
+ * @param File $image
* @return bool
*/
function isAnimatedImage( $image ) {
@@ -80,12 +93,14 @@ class PNGHandler extends BitmapHandler {
return true;
}
}
+
return false;
}
+
/**
* We do not support making APNG thumbnails, so always false
- * @param $image File
- * @return bool false
+ * @param File $image
+ * @return bool False
*/
function canAnimateThumbnail( $image ) {
return false;
@@ -108,19 +123,23 @@ class PNGHandler extends BitmapHandler {
if ( !$data || !is_array( $data ) ) {
wfDebug( __METHOD__ . " invalid png metadata\n" );
+
return self::METADATA_BAD;
}
if ( !isset( $data['metadata']['_MW_PNG_VERSION'] )
- || $data['metadata']['_MW_PNG_VERSION'] != PNGMetadataExtractor::VERSION ) {
+ || $data['metadata']['_MW_PNG_VERSION'] != PNGMetadataExtractor::VERSION
+ ) {
wfDebug( __METHOD__ . " old but compatible png metadata\n" );
+
return self::METADATA_COMPATIBLE;
}
+
return self::METADATA_GOOD;
}
/**
- * @param $image File
+ * @param File $image
* @return string
*/
function getLongDesc( $image ) {
@@ -155,4 +174,7 @@ class PNGHandler extends BitmapHandler {
return $wgLang->commaList( $info );
}
+ public function supportsBucketing() {
+ return true;
+ }
}