Index: src/wp-includes/class-wp-image-editor-imagick.php
===================================================================
--- src/wp-includes/class-wp-image-editor-imagick.php	(revision 40627)
+++ src/wp-includes/class-wp-image-editor-imagick.php	(working copy)
@@ -368,7 +368,17 @@
 			// Set appropriate quality settings after resizing.
 			if ( 'image/jpeg' == $this->mime_type ) {
 				if ( is_callable( array( $this->image, 'unsharpMaskImage' ) ) ) {
-					$this->image->unsharpMaskImage( 0.25, 0.25, 8, 0.065 );
+					// 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).
+					$do_unsharp = true;
+					if ( Imagick::COLORSPACE_CMYK === $this->image->getImageColorspace() ) {
+						$imagick_version = Imagick::getVersion();
+						if ( preg_match( '/[0-9]+\.[0-9]+\.[0-9]+-[0-9]+/', $imagick_version['versionString'], $matches ) ) {
+							$do_unsharp = version_compare( $matches[0], '6.8.4-0', '<' ) || version_compare( $matches[0], '6.9.6-4', '>' );
+						}
+					}
+					if ( $do_unsharp ) {
+						$this->image->unsharpMaskImage( 0.25, 0.25, 8, 0.065 );
+					}
 				}
 
 				$this->image->setOption( 'jpeg:fancy-upsampling', 'off' );
Index: tests/phpunit/tests/image/editor_imagick.php
===================================================================
--- tests/phpunit/tests/image/editor_imagick.php	(revision 40627)
+++ tests/phpunit/tests/image/editor_imagick.php	(working copy)
@@ -572,4 +572,26 @@
 		unlink( $ret['path'] );
 	}
 
+	/**
+	 * @ticket 39331
+	 * Note affects only ImageMagick versions 6.8.4-0 to 6.9.6-4.
+	 */
+	public function test_cmyk_jpg_resize() {
+		$test_file = DIR_TESTDATA . '/images/test_cmyk.jpg';
+		$save_to_file = tempnam( get_temp_dir(), '' ) . '.jpg';
+
+		$editor = new WP_Image_Editor_Imagick( $test_file );
+		$editor->load();
+		$editor->resize( 106, 150 ); // Default thumbnail size.
+		$editor->save( $save_to_file );
+
+		// Use GD as Imagick seems to do some color mapping of CMYK images.
+		$gd_image = imagecreatefromjpeg( $save_to_file );
+		// Pixel (15, 10) should be white.
+		$output = dechex( imagecolorat( $gd_image, 15, 10 ) );
+		imagedestroy( $gd_image );
+		$this->assertSame( 'ffffff', $output );
+
+		unlink( $save_to_file );
+	}
 }
