I want to convert a multipages PDF to a series of png files, while the PDF is portrait and png file is landscape, using imagemagick. I have achieve the conversion from PDF portrait to png protrait(code attached below). But have no idea how to make portrait image to landsacpe with no distortion, (not rotate the image). Can anyone kindly help me? Thanks.
$infile=$direcory."/Test.pdf";
$images=new Imagick();
$bodercolor=new ImagickPixel("white");
$images->setResolution(220, 220);
$images->readimage($infile);
$images->setimageformat("png");
foreach ($images as $i=>$image){
//set backgroud color = white
$image->setimagebordercolor($bodercolor);
$image->borderimage($bodercolor, 0, 0);
$image->writeimage($direcory."/test-pg".$i.".png");
}
$images->clear();
$images->destroy();
Actually, what I want is rotate the vertical page to horizontal with the objects on it have almost no changes. Like what we are able to do using Microsoft Word/PowerPoint when you change page orientation to landscape.