Index: trunk/phase3/tests/phpunit/includes/media/1bit-png.png |
Cannot display: file marked as a binary type. |
svn:mime-type = image/png |
Property changes on: trunk/phase3/tests/phpunit/includes/media/1bit-png.png |
___________________________________________________________________ |
Added: svn:mime-type |
1 | 1 | + image/png |
Property changes on: trunk/phase3/tests/phpunit/includes/media/broken_exif_date.jpg |
___________________________________________________________________ |
Modified: svn:mime-type |
2 | 2 | - application/octet-stream |
3 | 3 | + image/jpeg |
Index: trunk/phase3/tests/phpunit/includes/media/PNGMetadataExtractorTest.php |
— | — | @@ -0,0 +1,138 @@ |
| 2 | +<?php |
| 3 | +class PNGMetadataExtractorTest extends MediaWikiTestCase { |
| 4 | + /** |
| 5 | + * Tests zTXt tag (compressed textual metadata) |
| 6 | + */ |
| 7 | + function testPNGNativetzTXt() { |
| 8 | + $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . |
| 9 | + '/Png-native-test.png' ); |
| 10 | + $expected = "foo bar baz foo foo foo foof foo foo foo foo"; |
| 11 | + $this->assertArrayHasKey( 'text', $meta ); |
| 12 | + $meta = $meta['text']; |
| 13 | + $this->assertArrayHasKey( 'Make', $meta ); |
| 14 | + $this->assertArrayHasKey( 'x-default', $meta['Make'] ); |
| 15 | + |
| 16 | + $this->assertEquals( $expected, $meta['Make']['x-default'] ); |
| 17 | + } |
| 18 | + |
| 19 | + /** |
| 20 | + * Test tEXt tag (Uncompressed textual metadata) |
| 21 | + */ |
| 22 | + function testPNGNativetEXt() { |
| 23 | + $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . |
| 24 | + '/Png-native-test.png' ); |
| 25 | + $expected = "Some long image desc"; |
| 26 | + $this->assertArrayHasKey( 'text', $meta ); |
| 27 | + $meta = $meta['text']; |
| 28 | + $this->assertArrayHasKey( 'ImageDescription', $meta ); |
| 29 | + $this->assertArrayHasKey( 'x-default', $meta['ImageDescription'] ); |
| 30 | + $this->assertArrayHasKey( '_type', $meta['ImageDescription'] ); |
| 31 | + |
| 32 | + $this->assertEquals( $expected, $meta['ImageDescription']['x-default'] ); |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * tEXt tags must be encoded iso-8859-1 (vs iTXt which are utf-8) |
| 37 | + * Make sure non-ascii characters get converted properly |
| 38 | + */ |
| 39 | + function testPNGNativettEXtNonASCII() { |
| 40 | + $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . |
| 41 | + '/Png-native-test.png' ); |
| 42 | + |
| 43 | + // Note the Copyright symbol here is a utf-8 one |
| 44 | + // (aka \xC2\xA9) where in the file its iso-8859-1 |
| 45 | + // encoded as just \xA9. |
| 46 | + $expected = "© 2010 Bawolff"; |
| 47 | + |
| 48 | + |
| 49 | + $this->assertArrayHasKey( 'text', $meta ); |
| 50 | + $meta = $meta['text']; |
| 51 | + $this->assertArrayHasKey( 'Copyright', $meta ); |
| 52 | + $this->assertArrayHasKey( 'x-default', $meta['Copyright'] ); |
| 53 | + |
| 54 | + $this->assertEquals( $expected, $meta['Copyright']['x-default'] ); |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + * Test extraction of pHYs tags, which can tell what the |
| 59 | + * actual resolution of the image is (aka in dots per meter). |
| 60 | + function testPNGpHYsTag () { |
| 61 | + $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . |
| 62 | + '/Png-native-test.png' ); |
| 63 | + |
| 64 | + $this->assertArrayHasKey( 'text', $meta ); |
| 65 | + $meta = $meta['text']; |
| 66 | + |
| 67 | + $this->assertEquals( '2835/100', $meta['XResolution'] ); |
| 68 | + $this->assertEquals( '2835/100', $meta['YResolution'] ); |
| 69 | + $this->assertEquals( 3, $meta['ResolutionUnit'] ); // 3 = cm |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * Given a normal static PNG, check the animation metadata returned. |
| 74 | + */ |
| 75 | + function testStaticPNGAnimationMetadata() { |
| 76 | + $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . |
| 77 | + '/Png-native-test.png' ); |
| 78 | + |
| 79 | + $this->assertEquals( 0, $meta['frameCount'] ); |
| 80 | + $this->assertEquals( 1, $meta['loopCount'] ); |
| 81 | + $this->assertEquals( 0, $meta['duration'] ); |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * Given an animated APNG image file |
| 86 | + * check it gets animated metadata right. |
| 87 | + */ |
| 88 | + function testAPNGAnimationMetadata() { |
| 89 | + $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . |
| 90 | + '/Animated_PNG_example_bouncing_beach_ball.png' ); |
| 91 | + |
| 92 | + $this->assertEquals( 20, $meta['frameCount'] ); |
| 93 | + // Note loop count of 0 = infinity |
| 94 | + $this->assertEquals( 0, $meta['loopCount'] ); |
| 95 | + $this->assertEquals( 1.5, $meta['duration'], '', 0.00001 ); |
| 96 | + } |
| 97 | + |
| 98 | + function testPNGBitDepth8() { |
| 99 | + $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . |
| 100 | + '/Png-native-test.png' ); |
| 101 | + |
| 102 | + $this->assertEquals( 8, $meta['bitDepth'] ); |
| 103 | + } |
| 104 | + function testPNGBitDepth1() { |
| 105 | + $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . |
| 106 | + '/1bit-png.png' ); |
| 107 | + $this->assertEquals( 1, $meta['bitDepth'] ); |
| 108 | + } |
| 109 | + |
| 110 | + |
| 111 | + function testPNGindexColour() { |
| 112 | + $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . |
| 113 | + '/Png-native-test.png' ); |
| 114 | + |
| 115 | + $this->assertEquals( 'index-coloured', $meta['colorType'] ); |
| 116 | + } |
| 117 | + function testPNGrgbColour() { |
| 118 | + $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . |
| 119 | + '/rgb-png.png' ); |
| 120 | + $this->assertEquals( 'truecolour-alpha', $meta['colorType'] ); |
| 121 | + } |
| 122 | + function testPNGrgbNoAlphaColour() { |
| 123 | + $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . |
| 124 | + '/rgb-na-png.png' ); |
| 125 | + $this->assertEquals( 'truecolour', $meta['colorType'] ); |
| 126 | + } |
| 127 | + function testPNGgreyscaleColour() { |
| 128 | + $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . |
| 129 | + '/greyscale-png.png' ); |
| 130 | + $this->assertEquals( 'greyscale-alpha', $meta['colorType'] ); |
| 131 | + } |
| 132 | + function testPNGgreyscaleNoAlphaColour() { |
| 133 | + $meta = PNGMetadataExtractor::getMetadata( dirname( __FILE__ ) . |
| 134 | + '/greyscale-na-png.png' ); |
| 135 | + $this->assertEquals( 'greyscale', $meta['colorType'] ); |
| 136 | + } |
| 137 | + |
| 138 | + |
| 139 | +} |
Property changes on: trunk/phase3/tests/phpunit/includes/media/PNGMetadataExtractorTest.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 140 | + native |
Index: trunk/phase3/tests/phpunit/includes/media/Png-native-test.png |
Cannot display: file marked as a binary type. |
svn:mime-type = image/png |
Property changes on: trunk/phase3/tests/phpunit/includes/media/Png-native-test.png |
___________________________________________________________________ |
Added: svn:mime-type |
2 | 141 | + image/png |
Index: trunk/phase3/tests/phpunit/includes/media/rgb-na-png.png |
Cannot display: file marked as a binary type. |
svn:mime-type = image/png |
Property changes on: trunk/phase3/tests/phpunit/includes/media/rgb-na-png.png |
___________________________________________________________________ |
Added: svn:mime-type |
3 | 142 | + image/png |
Index: trunk/phase3/tests/phpunit/includes/media/rgb-png.png |
Cannot display: file marked as a binary type. |
svn:mime-type = image/png |
Property changes on: trunk/phase3/tests/phpunit/includes/media/rgb-png.png |
___________________________________________________________________ |
Added: svn:mime-type |
4 | 143 | + image/png |
Index: trunk/phase3/tests/phpunit/includes/media/Xmp-exif-multilingual_test.jpg |
Cannot display: file marked as a binary type. |
svn:mime-type = image/jpeg |
Property changes on: trunk/phase3/tests/phpunit/includes/media/Xmp-exif-multilingual_test.jpg |
___________________________________________________________________ |
Added: svn:mime-type |
5 | 144 | + image/jpeg |
Index: trunk/phase3/tests/phpunit/includes/media/greyscale-na-png.png |
Cannot display: file marked as a binary type. |
svn:mime-type = image/png |
Property changes on: trunk/phase3/tests/phpunit/includes/media/greyscale-na-png.png |
___________________________________________________________________ |
Added: svn:mime-type |
6 | 145 | + image/png |
Index: trunk/phase3/tests/phpunit/includes/media/greyscale-png.png |
Cannot display: file marked as a binary type. |
svn:mime-type = image/png |
Property changes on: trunk/phase3/tests/phpunit/includes/media/greyscale-png.png |
___________________________________________________________________ |
Added: svn:mime-type |
7 | 146 | + image/png |
Index: trunk/phase3/tests/phpunit/includes/media/Animated_PNG_example_bouncing_beach_ball.png |
Cannot display: file marked as a binary type. |
svn:mime-type = image/png |
Property changes on: trunk/phase3/tests/phpunit/includes/media/Animated_PNG_example_bouncing_beach_ball.png |
___________________________________________________________________ |
Added: svn:mime-type |
8 | 147 | + image/png |
Index: trunk/phase3/tests/phpunit/includes/media/README |
— | — | @@ -14,3 +14,15 @@ |
15 | 15 | CC-BY 3.0 |
16 | 16 | TastyCakes on English Wikipedia |
17 | 17 | |
| 18 | + |
| 19 | +greyscale-na-png.png, rgb-png.png, Xmp-exif-multilingual_test.jpg |
| 20 | +greyscale-png.png, 1bit-png.png, Png-native-test.png, rgb-na-png.png |
| 21 | +Are all by Bawolff. I don't think they contain enough originality to |
| 22 | +claim copyright, but on the off chance they do, feel free to use them |
| 23 | +however you feel fit, without restriction. |
| 24 | + |
| 25 | +Animated_PNG_example_bouncing_beach_ball.png |
| 26 | +http://commons.wikimedia.org/wiki/File:Animated_PNG_example_bouncing_beach_ball.png (originally http://www.treebuilder.de/default.asp?file=89031.xml ) |
| 27 | +Public Domain |
| 28 | +Holger Will |
| 29 | + |
Index: trunk/phase3/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php |
— | — | @@ -0,0 +1,27 @@ |
| 2 | +<?php |
| 3 | +class BitmapMetadataHandlerTest extends MediaWikiTestCase { |
| 4 | + /** |
| 5 | + * Test if having conflicting metadata values from different |
| 6 | + * types of metadata, that the right one takes precedence. |
| 7 | + * |
| 8 | + * Basically the file has IPTC and XMP metadata, the |
| 9 | + * IPTC should override the XMP, except for the multilingual |
| 10 | + * translation (to en) where XMP should win. |
| 11 | + */ |
| 12 | + public function testMultilingualCascade() { |
| 13 | + |
| 14 | + $meta = BitmapMetadataHandler::Jpeg( dirname( __FILE__ ) . |
| 15 | + '/Xmp-exif-multilingual_test.jpg' ); |
| 16 | + |
| 17 | + $expected = array( |
| 18 | + 'x-default' => 'right(iptc)', |
| 19 | + 'en' => 'right translation', |
| 20 | + '_type' => 'lang' |
| 21 | + ); |
| 22 | + |
| 23 | + $this->assertArrayHasKey( 'ImageDescription', $meta, |
| 24 | + 'Did not extract any ImageDescription info?!' ); |
| 25 | + |
| 26 | + $this->assertEquals( $expected, $meta['ImageDescription'] ); |
| 27 | + } |
| 28 | +} |
Property changes on: trunk/phase3/tests/phpunit/includes/media/BitmapMetadataHandlerTest.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 29 | + native |