From 8fdabdb621279e10d7a7e61e79cb87ec9dd742c6 Mon Sep 17 00:00:00 2001 From: Mike Schroder Date: Mon, 23 Sep 2019 10:35:45 +0000 Subject: [PATCH] Media: Prevent unnecessary whitespace around PDF Thumbnails. Stops unintended whitespace from showing around PDF thumbnails when the PDF creation tool utilized a CropBox. Props michelweimerskirch, joemcgill. Fixes #45598. git-svn-id: https://develop.svn.wordpress.org/trunk@46238 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-image-editor-imagick.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wp-includes/class-wp-image-editor-imagick.php b/src/wp-includes/class-wp-image-editor-imagick.php index 45a119c9c9..c014696b38 100644 --- a/src/wp-includes/class-wp-image-editor-imagick.php +++ b/src/wp-includes/class-wp-image-editor-imagick.php @@ -787,6 +787,10 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { // We want the thumbnail to be readable, so increase the rendering DPI. $this->image->setResolution( 128, 128 ); + // When generating thumbnails from cropped PDF pages, Imagemagick uses the uncropped + // area (resulting in unnecessary whitespace) unless the following option is set. + $this->image->setOption( 'pdf:use-cropbox', true ); + // Only load the first page. return $this->file . '[0]'; } catch ( Exception $e ) {