Summery Summery

Sets up Imagick for PDF processing.

Syntax Syntax


Description Description

Increases rendering DPI and only loads first page.

Return Return

(string|WP_Error) File to load or WP_Error on failure.

Source Source

File: wp-includes/class-wp-image-editor-imagick.php

		try {
			// By default, PDFs are rendered in a very low resolution.
			// 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 ) {
			return new WP_Error( 'pdf_setup_failed', $e->getMessage(), $this->file );


Changelog Changelog

Version Description
4.7.0 Introduced.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.