version 3.0.1 being in the last image or the first image in an imaginary object
$image_obj = new Imagick("test.pdf"); then you are in the last image in $ image_obj
if you use
fp_pdf = fopen("test.pdf", 'rb'); $image_obj = new Imagick(); $image_obj -> readImageFile($fp_pdf);
then you are on the first image in $ image_obj
In the second case, to switch to the last image, you can do
fp_pdf = fopen("test.pdf", 'rb'); $image_obj = new Imagick(); $image_obj -> readImageFile($fp_pdf,2); // 2 can be any positive number?
then you are in the last image in $ image_obj
echo $image_obj->getNumberImages()
then
if ($image_obj->hadPreviousImage) $image_obj->previousImage()
or
if ($image_obj->hasNextImage()) { $image_obj->nextImage())
eg. if you have only 6 images and you need 4, then do from the end
$image_obj->previousImage() $image_obj->previousImage() $image_obj->setImageFormat("png"); header("Content-Type: image/png"); echo $image_obj;
EDIT: Another find is that you can
foreach($image_obj as $slides) { echo "<br>".$Obj_img->getImageWidth();
EDIT 2: A very simple solution is to use this function $image_obj->setIteratorIndex(4) count starts from scratch.
source share