When I tried to convert the PDF to an image, the resulting image can be different from the original PDF

28 Views Asked by At

When I tried to convert the PDF to an image, the resulting image can be different from the original PDF.

This is my pdf

this is convert pdf to image output file

The resulting image may have a completely different color on the graphics background.

this is my code

$outputFolder = $pathToImage;
$imagick = new Imagick();
$imagick->setResolution(300, 300);
$imagick->readImage($pdfPath);
foreach ($imagick as $pageNumber => $page) {
  $page->setImageFormat('png');
  $page->setColorspace(Imagick::COLORSPACE_RGB);
  $page->setImageRenderingIntent(Imagick::RENDERINGINTENT_PERCEPTUAL);
  $outputFilename = $outputFolder . 'output_' . ($pageNumber + 1) . '.png';
  $page->writeImage($outputFilename);
  chmod($outputFilename, 0777);
 }


i am would like expection same background colour or imageSorry, I accidentally made changes again. It is now ready for QA. if convert time, please anyone suggest or different library i am using php5.6

0

There are 0 best solutions below