When I tried to convert the PDF to an image, the resulting image can be different from the original 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);
}