【发布时间】:2014-09-16 21:48:09
【问题描述】:
我想使用 imagemagick 将多页 PDF 转换为一系列 png 文件,而 PDF 是纵向的,而 png 文件是横向的。我已经实现了从 PDF 肖像到 png protrait 的转换(代码附在下面)。但是不知道如何将肖像图像制作成没有失真的横向图像(不旋转图像)。 任何人都可以帮助我吗?谢谢。
$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();
实际上,我想要的是将垂直页面旋转到水平,其上的对象几乎没有变化。就像当您将页面方向更改为横向时我们可以使用 Microsoft Word/PowerPoint 执行的操作一样。
【问题讨论】:
-
您无法在不扭曲或裁剪矩形的情况下更改矩形的纵横比(即将高矩形变为宽矩形)。
-
感谢您的回复。我刚刚编辑了我的帖子。请看最后一段,它说明了我真正想要的。你有什么想法吗,维扎德?还是其他人?
标签: php pdf ghostscript imagemagick-convert