Skip to content

Commit

Permalink
Media: Prevent unnecessary whitespace around PDF Thumbnails.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
getsource committed Sep 23, 2019
1 parent c9a2fde commit 8fdabdb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/wp-includes/class-wp-image-editor-imagick.php
Expand Up @@ -787,6 +787,10 @@ protected function pdf_setup() {
// 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 ) {
Expand Down

0 comments on commit 8fdabdb

Please sign in to comment.