I need the uploaded pdf to be converted to one long png image. Simple images (e.g. jpg) works fine and also pdf do if i just convert the last page (default). However when a try to convert all the pages of the pdf into one png it produces a long black image or a long black image with a white strip.
if ($file === null || !($file instanceof UploadedFile)) {
throw new \LogicException('No uploadable file found');
}
$tmpFile = $file->getRealPath();
try {
$im = new \imagick();
$im->pingimage($tmpFile);
$im->setresolution(140, 140);
$im->readimage($tmpFile);
switch ($file->getMimeType()) {
case 'application/pdf':
$im->resetIterator();
$ima = $im->appendImages(true);
$ima->setImageFormat('png');
$ima->writeImage();
$ima->clear();
$ima->destroy();
break;
default:
break; //return new Response('error');
}