WP_Image_Editor_Imagick::pdf_setup()protectedWP 4.7.0

Sets up Imagick for PDF processing. Increases rendering DPI and only loads first page.

Method of the class: WP_Image_Editor_Imagick{}

No Hooks.

Return

String|WP_Error. File to load or WP_Error on failure.

Usage

// protected - for code of main (parent) or child class
$result = $this->pdf_setup();

Changelog

Since 4.7.0 Introduced.

WP_Image_Editor_Imagick::pdf_setup() code WP 6.6.2

protected function pdf_setup() {
	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 );

		// Only load the first page.
		return $this->file . '[0]';
	} catch ( Exception $e ) {
		return new WP_Error( 'pdf_setup_failed', $e->getMessage(), $this->file );
	}
}