當從 ImageBlob 讀取 PDF,並且想要設定要使用的頁面時,這是要使用的函式。
(PECL imagick 2, PECL imagick 3)
Imagick::setImageIndex — 設定迭代器的位置
此函式從 Imagick 3.4.4 開始已過時。強烈建議不要依賴此函式。
index
要將迭代器設定到的位置
成功時回傳 true
。
發生錯誤時丟出 ImagickException。
當您使用 getImageBlog 讀取 pdf 並想要取得特定頁面的影像或 blob 時,請如下使用此函式。
$ims = new Imagick();
$ims->readImageBlob($pdfFileContent);
$ims->setImageIndex(5); //這將回傳 pdf 檔案的第 6 頁
$image->setImageFormat('png');
//等等
$blob = $image->getImageBlob();