3 * Tests related to JPEG chroma subsampling via $wgJpegPixelFormat setting.
10 class JpegPixelFormatTest
extends MediaWikiMediaTestCase
{
12 protected function setUp() {
17 * Mark this test as creating thumbnail files.
19 protected function createsThumbnails() {
25 * @dataProvider providePixelFormats
27 public function testPixelFormatRendering( $sourceFile, $pixelFormat, $samplingFactor ) {
28 global $wgUseImageMagick, $wgUseImageResize;
29 if ( !$wgUseImageMagick ) {
30 $this->markTestSkipped( "This test is only applicable when using ImageMagick thumbnailing" );
32 if ( !$wgUseImageResize ) {
33 $this->markTestSkipped( "This test is only applicable when using thumbnailing" );
36 $fmtStr = var_export( $pixelFormat, true );
37 $this->setMwGlobals( 'wgJpegPixelFormat', $pixelFormat );
39 $file = $this->dataFile( $sourceFile, 'image/jpeg' );
44 $thumb = $file->transform( $params, File
::RENDER_NOW | File
::RENDER_FORCE
);
45 $this->assertTrue( !$thumb->isError(), "created JPEG thumbnail for pixel format $fmtStr" );
47 $path = $thumb->getLocalCopyPath();
48 $this->assertTrue( is_string( $path ), "path returned for JPEG thumbnail for $fmtStr" );
53 '%[jpeg:sampling-factor]',
57 $output = wfShellExec( $cmd, $retval );
58 $this->assertTrue( $retval === 0, "ImageMagick's identify command should return success" );
60 $expected = $samplingFactor;
61 $actual = trim( $output );
65 "IM identify expects JPEG chroma subsampling \"$expected\" for $fmtStr"
69 public static function providePixelFormats() {
71 // From 4:4:4 source file
92 // From 4:2:0 source file