PHPCon Poland 2024


(PECL imagick 2, PECL imagick 3)

Imagick::getNumberImagesRetourne le nombre d'images d'un objet


public Imagick::getNumberImages(): int

Retourne le nombre d'image d'un objet Imagick.

Liste de paramètres

Cette fonction ne contient aucun paramètre.

Valeurs de retour

Retourne le nombre d'image d'un objet Imagick.

Erreurs / Exceptions

Lance une exception ImagickException si une erreur survient.

add a note

User Contributed Notes 2 notes

gzabriskie at yahoo dot com
15 years ago
/* Create the object */
$image = new Imagick('YourImageLocation.tif');
$count = $image->getNumberImages();

"<h3 style=\"font: bold 12pt Arial\">Total Number of Images Extracted ".
"from the TIF : ".$image->getNumberImages()."</h3>";

for (
$x = 1;$x <= $image->getNumberImages(); $x++) {
$image->thumbnailImage( 400, null );

<title>Extracting Images Form TIFF</title>
<table cellspacing="10" style="background: #ddd"><tr>
for ($x = 1;$x <= $image->getNumberImages(); $x++) {
"<td><img src=\"img$x.png\"<br /><p style=\"font: bold 12pt Arial;".
"text-align: center\">image $x (png)</p></td>";
benkuhl at gmail dot com
11 years ago
For PDFs this function indicates the number of pages on the PDF, NOT images that might be embedded within the PDF.


= new Imagick('2_pager.pdf');

var_dump($document->getNumberImages()); //returns 2

$document = new Imagick('1_pager.pdf');

var_dump($document->getNumberImages()); //returns 1


From my research it is not possible to obtain the images embedded within a PDF by using the PHP Imagick library.
To Top