WordPress.org

Make WordPress Core

Ticket #38522: 38522.diff

File 38522.diff, 1.1 KB (added by mikeschroder, 4 years ago)

Only read first page.

  • src/wp-includes/class-wp-image-editor-imagick.php

    diff --git a/src/wp-includes/class-wp-image-editor-imagick.php b/src/wp-includes/class-wp-image-editor-imagick.php
    index fb56eb1..c89706c 100644
    a b class WP_Image_Editor_Imagick extends WP_Image_Editor { 
    147147                try {
    148148                        $this->image = new Imagick();
    149149                        $file_parts = pathinfo( $this->file );
     150                        $filename = $this->file;
    150151
    151152                        // By default, PDFs are rendered in a very low resolution.
    152153                        // We want the thumbnail to be readable, so increase the rendering dpi.
    153154                        if ( 'pdf' == strtolower( $file_parts['extension'] ) ) {
    154155                                $this->image->setResolution( 128, 128 );
     156
     157                                // Only load the first page.
     158                                $filename .= '[0]';
    155159                        }
    156160
    157161                        // Reading image after Imagick instantiation because `setResolution`
    158162                        // only applies correctly before the image is read.
    159                         $this->image->readImage( $this->file );
     163                        $this->image->readImage( $filename );
    160164
    161165                        if ( ! $this->image->valid() )
    162166                                return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file);