3 * Tests related to JPEG chroma subsampling via $wgJpegPixelFormat setting.
8 class JpegPixelFormatTest
extends MediaWikiMediaTestCase
{
10 protected function setUp() {
15 * Mark this test as creating thumbnail files.
17 protected function createsThumbnails() {
23 * @dataProvider providePixelFormats
24 * @covers BitmapHandler::imageMagickSubsampling
26 public function testPixelFormatRendering( $sourceFile, $pixelFormat, $samplingFactor ) {
27 global $wgUseImageMagick, $wgUseImageResize;
28 if ( !$wgUseImageMagick ) {
29 $this->markTestSkipped( "This test is only applicable when using ImageMagick thumbnailing" );
31 if ( !$wgUseImageResize ) {
32 $this->markTestSkipped( "This test is only applicable when using thumbnailing" );
35 $fmtStr = var_export( $pixelFormat, true );
36 $this->setMwGlobals( 'wgJpegPixelFormat', $pixelFormat );
38 $file = $this->dataFile( $sourceFile, 'image/jpeg' );
43 $thumb = $file->transform( $params, File
::RENDER_NOW | File
::RENDER_FORCE
);
44 $this->assertTrue( !$thumb->isError(), "created JPEG thumbnail for pixel format $fmtStr" );
46 $path = $thumb->getLocalCopyPath();
47 $this->assertTrue( is_string( $path ), "path returned for JPEG thumbnail for $fmtStr" );
52 '%[jpeg:sampling-factor]',
56 $output = wfShellExec( $cmd, $retval );
57 $this->assertTrue( $retval === 0, "ImageMagick's identify command should return success" );
59 $expected = $samplingFactor;
60 $actual = trim( $output );
64 "IM identify expects JPEG chroma subsampling \"$expected\" for $fmtStr"
68 public static function providePixelFormats() {
70 // From 4:4:4 source file
91 // From 4:2:0 source file