WP_Image_Editor_Imagick::pdf_load_source()protectedWP 5.6.0

Load the image produced by Ghostscript.

Includes a workaround for a bug in Ghostscript 8.70 that prevents processing of some PDF files when use-cropbox is set.

Метод класса: WP_Image_Editor_Imagick{}

Хуков нет.

Возвращает

true|WP_Error.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->pdf_load_source();

Список изменений

С версии 5.6.0 Введена.

Код WP_Image_Editor_Imagick::pdf_load_source() WP 6.4.3

protected function pdf_load_source() {
	$filename = $this->pdf_setup();

	if ( is_wp_error( $filename ) ) {
		return $filename;
	}

	try {
		/*
		 * 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 );

		/*
		 * Reading image after Imagick instantiation because `setResolution`
		 * only applies correctly before the image is read.
		 */
		$this->image->readImage( $filename );
	} catch ( Exception $e ) {
		// Attempt to run `gs` without the `use-cropbox` option. See #48853.
		$this->image->setOption( 'pdf:use-cropbox', false );

		$this->image->readImage( $filename );
	}

	return true;
}