Creating JPG thumbnails from PDF causes problems with version 6.8.9 of ImageMagick
Posted: 2019-03-11T22:55:02-07:00
I am using Wordpress 5.1 and ImageMagick 6.8.9. When I upload PDF from the Media menu of WordPress then it creates JPG thumbnail with a black background.
First, I used default media import functionality of WP to import PDF files then I tried with my own script to create JPG thumbnail of the first page. Here it is
In both cases, it creates an image with a black background.
Does anyone have any idea about this?
First, I used default media import functionality of WP to import PDF files then I tried with my own script to create JPG thumbnail of the first page. Here it is
Code: Select all
$uploads = wp_upload_dir();
$imagick = new Imagick();
$imagick->readImage('test.pdf[0]');
$imagick->trimImage(2);
$imagick->setImagePage(0, 0, 0, 0);
$imagick->setImageFormat('jpeg');
file_put_contents($uploads['path'] . '/thumbnail.png', $imagick);
Does anyone have any idea about this?