将PDF转换为具有相同分辨率的PNG

I am trying to convert a PDF to a PNG using ghostscript and Imagick.

I have tried this:

o_imagick = new imagick(mydocu.pdf[0]);
$this->o_imagick->setImageFormat('png');
file_put_contents ("actualpdf.png", $this->o_imagick);

Which generates and saves a new image but the resolution is weird. I need it to be the same resolution as the PDF. I assumed it would just generate an exact PNG copy out of the PDF.

Any ideas?

PDF doesn't have a resolution, generally, its a scalable vector format. So your requirement doesn't make sense.

Its possible that the PDF contains an image, which can then have a resolution, but that's not quite the same thing.

If you posted an example PDF file we might be able to make some suggestions, but as it is there is not sufficient information.