X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/8989532d3de45b196373107c7a812a68ac0ff2d9..d75ce11339b35963b5f8c3d53190819c1c025716:/includes/media/GIF.php diff --git a/includes/media/GIF.php b/includes/media/GIF.php new file mode 100644 index 00000000..dbe5f813 --- /dev/null +++ b/includes/media/GIF.php @@ -0,0 +1,72 @@ +parsedGIFMetadata) ) { + try { + $image->parsedGIFMetadata = GIFMetadataExtractor::getMetadata( $filename ); + } catch( Exception $e ) { + // Broken file? + wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" ); + return '0'; + } + } + + return serialize($image->parsedGIFMetadata); + + } + + function formatMetadata( $image ) { + return false; + } + + function getImageArea( $image, $width, $height ) { + $ser = $image->getMetadata(); + if ($ser) { + $metadata = unserialize($ser); + return $width * $height * $metadata['frameCount']; + } else { + return $width * $height; + } + } + + function getMetadataType( $image ) { + return 'parsed-gif'; + } + + function getLongDesc( $image ) { + global $wgUser, $wgLang; + $sk = $wgUser->getSkin(); + + $metadata = @unserialize($image->getMetadata()); + + if (!$metadata) return parent::getLongDesc( $image ); + + $info = array(); + $info[] = $image->getMimeType(); + $info[] = $sk->formatSize( $image->getSize() ); + + if ($metadata['looped']) + $info[] = wfMsgExt( 'file-info-gif-looped', 'parseinline' ); + + if ($metadata['frameCount'] > 1) + $info[] = wfMsgExt( 'file-info-gif-frames', 'parseinline', $metadata['frameCount'] ); + + if ($metadata['duration']) + $info[] = $wgLang->formatTimePeriod( $metadata['duration'] ); + + $infoString = $wgLang->commaList( $info ); + + return "($infoString)"; + } +}