Make WordPress Core

Ticket #48853: 48853.diff

File 48853.diff, 1.3 KB (added by azaozz, 4 years ago)
  • src/wp-includes/class-wp-image-editor-imagick.php

     
    154154                                return new WP_Error( 'invalid_image', __( 'File is not an image.' ), $this->file );
    155155                        }
    156156
     157                        if ( 'pdf' === $file_extension ) {
     158                                // When generating thumbnails from cropped PDF pages, Imagemagick uses the uncropped
     159                                // area (resulting in unnecessary whitespace) unless the following option is set.
     160                                $this->image->setOption( 'pdf:use-cropbox', true );
     161                        }
     162
    157163                        // Select the first frame to handle animated images properly
    158164                        if ( is_callable( array( $this->image, 'setIteratorIndex' ) ) ) {
    159165                                $this->image->setIteratorIndex( 0 );
     
    794800                        // We want the thumbnail to be readable, so increase the rendering DPI.
    795801                        $this->image->setResolution( 128, 128 );
    796802
    797                         // When generating thumbnails from cropped PDF pages, Imagemagick uses the uncropped
    798                         // area (resulting in unnecessary whitespace) unless the following option is set.
    799                         $this->image->setOption( 'pdf:use-cropbox', true );
    800 
    801803                        // Only load the first page.
    802804                        return $this->file . '[0]';
    803805                } catch ( Exception $e ) {