For storage repos that support headers (such as Swift), this will store the original media dimensions as an extra custom header, X-Content-Dimensions. The header is formatted to minimize its length when dealing with multipage documents, by expressing the information as page ranges keyed by dimensions. Example for a multipage documents with some pages of different sizes: X-Content-Dimensions: 1903x899:1-9,11/1903x873:10 Example for a single page document: X-Content-Dimensions: 800x600:1 Bug: T150741 Change-Id: Ic4c6a86557b3705cf75d074753e9ce2ee070a6df
51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group Media
|
|
* @covers Exif
|
|
*/
|
|
class ExifTest extends MediaWikiTestCase {
|
|
|
|
/** @var string */
|
|
protected $mediaPath;
|
|
|
|
protected function setUp() {
|
|
parent::setUp();
|
|
$this->checkPHPExtension( 'exif' );
|
|
|
|
$this->mediaPath = __DIR__ . '/../../data/media/';
|
|
|
|
$this->setMwGlobals( 'wgShowEXIF', true );
|
|
}
|
|
|
|
public function testGPSExtraction() {
|
|
$filename = $this->mediaPath . 'exif-gps.jpg';
|
|
$seg = JpegMetadataExtractor::segmentSplitter( $filename );
|
|
$exif = new Exif( $filename, $seg['byteOrder'] );
|
|
$data = $exif->getFilteredData();
|
|
$expected = [
|
|
'GPSLatitude' => 88.5180555556,
|
|
'GPSLongitude' => -21.12357,
|
|
'GPSAltitude' => -3.141592653,
|
|
'GPSDOP' => '5/1',
|
|
'GPSVersionID' => '2.2.0.0',
|
|
'Height' => 10,
|
|
'Width' => 40,
|
|
];
|
|
$this->assertEquals( $expected, $data, '', 0.0000000001 );
|
|
}
|
|
|
|
public function testUnicodeUserComment() {
|
|
$filename = $this->mediaPath . 'exif-user-comment.jpg';
|
|
$seg = JpegMetadataExtractor::segmentSplitter( $filename );
|
|
$exif = new Exif( $filename, $seg['byteOrder'] );
|
|
$data = $exif->getFilteredData();
|
|
|
|
$expected = [
|
|
'UserComment' => 'test⁔comment',
|
|
'Height' => 10,
|
|
'Width' => 40,
|
|
];
|
|
$this->assertEquals( $expected, $data );
|
|
}
|
|
}
|