Index: src/wp-includes/class-wp-image-editor-imagick.php
===================================================================
--- src/wp-includes/class-wp-image-editor-imagick.php	(revision 39616)
+++ src/wp-includes/class-wp-image-editor-imagick.php	(working copy)
@@ -164,6 +164,10 @@
 			if ( is_callable( array( $this->image, 'setIteratorIndex' ) ) )
 				$this->image->setIteratorIndex(0);
 
+			if ( 'pdf' == $file_extension ) {
+				$this->pdf_process();
+			}
+
 			$this->mime_type = $this->get_mime_type( $this->image->getImageFormat() );
 		}
 		catch ( Exception $e ) {
@@ -367,7 +371,8 @@
 
 			// Set appropriate quality settings after resizing.
 			if ( 'image/jpeg' == $this->mime_type ) {
-				if ( is_callable( array( $this->image, 'unsharpMaskImage' ) ) ) {
+				// Not compatible with CMYK color spaces.
+				if ( is_callable( array( $this->image, 'unsharpMaskImage' ) && Imagick::COLORSPACE_CMYK !== $this->image->getImageColorspace() ) ) {
 					$this->image->unsharpMaskImage( 0.25, 0.25, 8, 0.065 );
 				}
 
@@ -761,4 +766,27 @@
 		}
 	}
 
+	/**
+	 * Process PDF after it's been read.
+	 * Remove alpha channel to avoid black backgrounds.
+	 *
+	 * @since 4.x
+	 * @access protected
+	 *
+	 * @return void
+	 */
+	protected function pdf_process() {
+		$version = Imagick::getVersion();
+		// Remove alpha channel if possible to avoid black backgrounds. RemoveAlphaChannel added in ImageMagick 6.7.5.
+		if ( $version['versionNumber'] >= 0x675 ) {
+			try {
+				// Imagick::ALPHACHANNEL_REMOVE mapped to RemoveAlphaChannel in PHP imagick 3.2.0b2.
+				// Value seems to have remained stable at 12 for ImageMagick 6.7.5 to 7.0 (although other AlphaChannelType enum values have changed).
+				$this->image->setImageAlphaChannel( defined( 'Imagick::ALPHACHANNEL_REMOVE' ) ? Imagick::ALPHACHANNEL_REMOVE : 12 );
+			}
+			catch ( Exception $e ) {
+				// Ignore.
+			}
+		}
+	}
 }
Index: tests/phpunit/tests/image/editor_imagick.php
===================================================================
--- tests/phpunit/tests/image/editor_imagick.php	(revision 39616)
+++ tests/phpunit/tests/image/editor_imagick.php	(working copy)
@@ -542,4 +542,69 @@
 
 		$this->assertTrue( $result );
 	}
+
+	/**
+	 * @ticket 39216
+	 */
+	public function test_remove_alpha_pdf_preview() {
+		if ( ! wp_image_editor_supports( array( 'mime_type' => 'application/pdf' ) ) ) {
+			$this->markTestSkipped( 'Rendering PDFs is not supported on this system.' );
+		}
+
+		$test_file = DIR_TESTDATA . '/images/test_alpha.pdf';
+		$attachment_id = $this->factory->attachment->create_upload_object( $test_file );
+		$this->assertNotEmpty( $attachment_id );
+
+		$attached_file = get_attached_file( $attachment_id );
+		$this->assertNotEmpty( $attached_file );
+
+		$check = image_get_intermediate_size( $attachment_id, 'thumbnail' );
+		$this->assertNotEmpty( $check['file'] );
+		$check_file = path_join( dirname( $attached_file ), $check['file'] );
+
+		$rgb = array( 'r' => true, 'g' => true, 'b' => true ); // Used for intersecting - not interested in alpha channel.
+		$imagick = new Imagick( $check_file );
+		$expected = array( 'r' => 1, 'g' => 1, 'b' => 1 ); // White.
+		$output = array_map( 'round', array_intersect_key( $imagick->getImagePixelColor( 1, 1 )->getColor( true /*normalized*/ ), $rgb ) );
+		$this->assertEquals( $expected, $output ); // Allow for floating point equivalence.
+		$imagick->destroy();
+
+		$check = image_get_intermediate_size( $attachment_id, 'full' );
+		$this->assertNotEmpty( $check['file'] );
+		$check_file = path_join( dirname( $attached_file ), $check['file'] );
+
+		$imagick = new Imagick( $check_file );
+		$expected = array( 'r' => 1, 'g' => 1, 'b' => 1 ); // White.
+		$output = array_map( 'round', array_intersect_key( $imagick->getImagePixelColor( 100, 100 )->getColor( true /*normalized*/ ), $rgb ) );
+		$this->assertEquals( $expected, $output ); // Allow for floating point equivalence.
+		$imagick->destroy();
+	}
+
+	/**
+	 * @ticket 39216
+	 */
+	public function test_convert_cmyk_pdf_preview() {
+		if ( ! wp_image_editor_supports( array( 'mime_type' => 'application/pdf' ) ) ) {
+			$this->markTestSkipped( 'Rendering PDFs is not supported on this system.' );
+		}
+
+		$test_file = DIR_TESTDATA . '/images/test_cmyk.pdf';
+		$attachment_id = $this->factory->attachment->create_upload_object( $test_file );
+		$this->assertNotEmpty( $attachment_id );
+
+		$attached_file = get_attached_file( $attachment_id );
+		$this->assertNotEmpty( $attached_file );
+
+		$check = image_get_intermediate_size( $attachment_id, 'thumbnail' );
+		$this->assertNotEmpty( $check['file'] );
+		$check_file = path_join( dirname( $attached_file ), $check['file'] );
+
+		// Use GD as Imagick seems to do some color mapping of CMYK images.
+		$gd_image = imagecreatefromjpeg( $check_file );
+		// Not sure how system-independent this is.
+		// Pixel (15, 10) should be white.
+		$output = dechex( imagecolorat( $gd_image, 15, 10 ) );
+		imagedestroy( $gd_image );
+		$this->assertSame( 'ffffff', $output );
+	}
 }
