2011-08-21 18:05:34 +00:00
|
|
|
|
<?php
|
2014-07-15 17:31:07 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @group Media
|
|
|
|
|
|
*/
|
2011-08-21 18:05:34 +00:00
|
|
|
|
class GIFMetadataExtractorTest extends MediaWikiTestCase {
|
|
|
|
|
|
|
2012-10-08 10:56:20 +00:00
|
|
|
|
protected function setUp() {
|
|
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
2012-08-27 19:03:15 +00:00
|
|
|
|
$this->mediaPath = __DIR__ . '/../../data/media/';
|
2011-08-21 18:05:34 +00:00
|
|
|
|
}
|
2013-02-15 10:17:52 +00:00
|
|
|
|
|
2011-08-21 18:05:34 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Put in a file, and see if the metadata coming out is as expected.
|
2014-04-17 18:43:42 +00:00
|
|
|
|
* @param string $filename
|
|
|
|
|
|
* @param array $expected The extracted metadata.
|
2012-10-08 10:56:20 +00:00
|
|
|
|
* @dataProvider provideGetMetadata
|
2013-10-23 22:12:39 +00:00
|
|
|
|
* @covers GIFMetadataExtractor::getMetadata
|
2011-08-21 18:05:34 +00:00
|
|
|
|
*/
|
|
|
|
|
|
public function testGetMetadata( $filename, $expected ) {
|
|
|
|
|
|
$actual = GIFMetadataExtractor::getMetadata( $this->mediaPath . $filename );
|
|
|
|
|
|
$this->assertEquals( $expected, $actual );
|
|
|
|
|
|
}
|
2013-02-15 10:17:52 +00:00
|
|
|
|
|
2012-10-08 10:56:20 +00:00
|
|
|
|
public static function provideGetMetadata() {
|
2011-08-21 18:05:34 +00:00
|
|
|
|
$xmpNugget = <<<EOF
|
|
|
|
|
|
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
|
|
|
|
|
|
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 7.30'>
|
|
|
|
|
|
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
|
|
|
|
|
|
|
|
|
|
|
|
<rdf:Description rdf:about=''
|
|
|
|
|
|
xmlns:Iptc4xmpCore='http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/'>
|
|
|
|
|
|
<Iptc4xmpCore:Location>The interwebs</Iptc4xmpCore:Location>
|
|
|
|
|
|
</rdf:Description>
|
|
|
|
|
|
|
|
|
|
|
|
<rdf:Description rdf:about=''
|
|
|
|
|
|
xmlns:tiff='http://ns.adobe.com/tiff/1.0/'>
|
|
|
|
|
|
<tiff:Artist>Bawolff</tiff:Artist>
|
|
|
|
|
|
<tiff:ImageDescription>
|
|
|
|
|
|
<rdf:Alt>
|
|
|
|
|
|
<rdf:li xml:lang='x-default'>A file to test GIF</rdf:li>
|
|
|
|
|
|
</rdf:Alt>
|
|
|
|
|
|
</tiff:ImageDescription>
|
|
|
|
|
|
</rdf:Description>
|
|
|
|
|
|
</rdf:RDF>
|
|
|
|
|
|
</x:xmpmeta>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<?xpacket end='w'?>
|
|
|
|
|
|
EOF;
|
2011-11-04 20:46:04 +00:00
|
|
|
|
$xmpNugget = str_replace( "\r", '', $xmpNugget ); // Windows compat
|
2011-08-21 18:05:34 +00:00
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
|
return [
|
|
|
|
|
|
[
|
2013-02-15 10:17:52 +00:00
|
|
|
|
'nonanimated.gif',
|
2016-02-17 09:09:32 +00:00
|
|
|
|
[
|
|
|
|
|
|
'comment' => [ 'GIF test file ⁕ Created with GIMP' ],
|
2013-02-15 10:17:52 +00:00
|
|
|
|
'duration' => 0.1,
|
|
|
|
|
|
'frameCount' => 1,
|
|
|
|
|
|
'looped' => false,
|
|
|
|
|
|
'xmp' => '',
|
2016-02-17 09:09:32 +00:00
|
|
|
|
]
|
|
|
|
|
|
],
|
|
|
|
|
|
[
|
2013-02-15 10:17:52 +00:00
|
|
|
|
'animated.gif',
|
2016-02-17 09:09:32 +00:00
|
|
|
|
[
|
|
|
|
|
|
'comment' => [ 'GIF test file . Created with GIMP' ],
|
2013-02-15 10:17:52 +00:00
|
|
|
|
'duration' => 2.4,
|
|
|
|
|
|
'frameCount' => 4,
|
|
|
|
|
|
'looped' => true,
|
|
|
|
|
|
'xmp' => '',
|
2016-02-17 09:09:32 +00:00
|
|
|
|
]
|
|
|
|
|
|
],
|
2011-08-21 18:05:34 +00:00
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
|
[
|
2013-02-15 10:17:52 +00:00
|
|
|
|
'animated-xmp.gif',
|
2016-02-17 09:09:32 +00:00
|
|
|
|
[
|
2013-02-15 10:17:52 +00:00
|
|
|
|
'xmp' => $xmpNugget,
|
|
|
|
|
|
'duration' => 2.4,
|
|
|
|
|
|
'frameCount' => 4,
|
|
|
|
|
|
'looped' => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
|
'comment' => [ 'GIƒ·test·file' ],
|
|
|
|
|
|
]
|
|
|
|
|
|
],
|
|
|
|
|
|
];
|
2011-08-21 18:05:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|