<?php
bool public Imagick::setImageFormat(string $format);
?>
<?php
$imagick = new Imagick();
$pngfn = PATH2IMGW . '/png/wizard.png';
$imagick->readImage($pngfn);
// Returns a large PNG
$pngData = $imagick->getImageBlob();
$imagick->setImageFormat('pdf');
// Returns pdf blob string immediately
$pdfData = $imagick->getImageBlob();
echo "PNG:<br>" . $pngData;
echo '<br><br><br>PDF:<br>';
echo $pdfData;
?>
<?php
$imagick = new Imagick();
$pngfn = PATH2IMGW . '/png/wizard.png';
$imagick->readImage($pngfn);
$formats = $imagick->queryFormats();
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RUN this exercice several times...
Each time it is executed a
new result will be obtained.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
$nbr = count($formats);
$rnd = mt_rand(0, $nbr - 1);
$pngData = $imagick->getImageBlob();
$imagick->setImageFormat($formats[$rnd]);
$Data = $imagick->getImageBlob();
echo "[$rnd] -> $formats[$rnd]<br><br>";
echo $Data;
?>
<?php
$imagick = new Imagick();
$pngfn = PATH2IMGW . '/png/wizard.png';
$str3img = PATH2IMGL . '/results/wizard new.bmp';
$imagick->readImage($pngfn);
$pngData = $imagick->getImageBlob();
$imagick->setImageFormat('png');
$pngData = $imagick->getImageBlob();
echo $pngData . '<br><br>';
echo "BMP:<br><br>";
$img = imagecreatefromstring($pngData);
imagebmp($img, $str3img);
echo basename($str3img); ?>
<br><br>The image created by the use of this STRING:
<br><br>
<img src="<?php echo $str3img; ?>"
alt="<?php echo $str3img; ?>"
title="<?php echo $str3img; ?>">
<?php
$image = new Imagick();
$image->newImage(1, 1, new ImagickPixel('#ffffff'));
$image->setImageFormat('png');
$pngData = $image->getImagesBlob();
echo strpos($pngData, "\x89PNG\r\n\x1a\n") === 0 ? 'Ok' : 'Failed';
?>