Ticket #39331: 39331.2.patch
File 39331.2.patch, 2.2 KB (added by , 8 years ago) |
---|
-
src/wp-includes/class-wp-image-editor-imagick.php
368 368 // Set appropriate quality settings after resizing. 369 369 if ( 'image/jpeg' == $this->mime_type ) { 370 370 if ( is_callable( array( $this->image, 'unsharpMaskImage' ) ) ) { 371 $this->image->unsharpMaskImage( 0.25, 0.25, 8, 0.065 ); 371 // Not compatible with CMYK color spaces for ImageMagick versions 6.8.4-0 to 6.9.6-4 (https://github.com/ImageMagick/ImageMagick/issues/299). 372 $do_unsharp = true; 373 if ( Imagick::COLORSPACE_CMYK === $this->image->getImageColorspace() ) { 374 $imagick_version = Imagick::getVersion(); 375 if ( preg_match( '/[0-9]+\.[0-9]+\.[0-9]+-[0-9]+/', $imagick_version['versionString'], $matches ) ) { 376 $do_unsharp = version_compare( $matches[0], '6.8.4-0', '<' ) || version_compare( $matches[0], '6.9.6-4', '>' ); 377 } 378 } 379 if ( $do_unsharp ) { 380 $this->image->unsharpMaskImage( 0.25, 0.25, 8, 0.065 ); 381 } 372 382 } 373 383 374 384 $this->image->setOption( 'jpeg:fancy-upsampling', 'off' ); -
tests/phpunit/tests/image/editor_imagick.php
572 572 unlink( $ret['path'] ); 573 573 } 574 574 575 /** 576 * @ticket 39331 577 * Note affects only ImageMagick versions 6.8.4-0 to 6.9.6-4. 578 */ 579 public function test_cmyk_jpg_resize() { 580 $test_file = DIR_TESTDATA . '/images/test_cmyk.jpg'; 581 $save_to_file = tempnam( get_temp_dir(), '' ) . '.jpg'; 582 583 $editor = new WP_Image_Editor_Imagick( $test_file ); 584 $editor->load(); 585 $editor->resize( 106, 150 ); // Default thumbnail size. 586 $editor->save( $save_to_file ); 587 588 // Use GD as Imagick seems to do some color mapping of CMYK images. 589 $gd_image = imagecreatefromjpeg( $save_to_file ); 590 // Pixel (15, 10) should be white. 591 $output = dechex( imagecolorat( $gd_image, 15, 10 ) ); 592 imagedestroy( $gd_image ); 593 $this->assertSame( 'ffffff', $output ); 594 595 unlink( $save_to_file ); 596 } 575 597 }