PHP imagick get all images from tiff -
i trying load tiff file , count number or images , then dispaly each image png thumbnail.
the count part ok counts 6 correct number of pages in tif, code lists 6 of same image the first page of tiff. cant workout if there problem loop or not using imagick functions correctly.
can help
<?php $image2 = new imagick('http://mysite.org.uk/tiftest/2.tif'); /* create object */ $image = new imagick('http://mysite.org.uk/tiftest/2.tif'); $count = $image->getnumberimages(); echo "<h3 style=\"font: bold 12pt arial\">total number of images extracted ". "from tif : ".$image->getnumberimages()."</h3>"; ($x = 1;$x <= $image->getnumberimages();$x++) { $image->pingimage( $image2 ); $image->readimagefile( $image2 ); $image->setimageformat( 'png' ); $image->thumbnailimage(100, 0); echo "<img id='" . $x . "' src='data:image/png;base64,".base64_encode($image)."' />"; } ?>
you have move previous image using $image->previousimage()
iterate on number of images backwards , move previous image of them, might able use while ($image->haspreviousimage()) {} construct
oh, , dont use readimagefile, have image in-memory.
Comments
Post a Comment