WP_Image_Editor_Imagick::pdf_setup(): string|WP_Error

Sets up Imagick for PDF processing.


Description

Increases rendering DPI and only loads first page.


Top ↑

Return

string|WP_Error File to load or WP_Error on failure.


Top ↑

Source

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

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 );
	}
}


Top ↑

Changelog

Changelog
Version Description
4.7.0 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.