Imagick::getImageBlob


wizard apg

RETURNS the image sequence as a blob.



<?php

string 
public Imagick::getImageBlob();

?>

 


This function has no parameters.





Implements direct to memory image formats.

It returns the image sequence as a string.

The format of the image determines the format of the returned blob:

(GIF, JPEG, PNG, etc.)



  1 EXERCISE   

<?php

// Run this exercise to see the ImageBlob

$imagick = new Imagick();

$jpgfn = PATH2IMGW . '/jpg/wizard.jpg';

$imagick->readImage($jpgfn);

$strg = $imagick->getImageBlob();

echo 
$strg;

?>

  2 EXERCISE   

<?php

// Run this exercise to see another ImageBlob

$imagick = new Imagick();

$giffn = PATH2IMGW . '/gif/E 01 01.gif';

$imagick->readImage($giffn);

$strg = $imagick->getImageBlob();

echo 
$strg;

?>

  3 EXERCISE   

<?php

// Run this exercise to see one more ImageBlob

$imagick = new Imagick();

$pngfn = PATH2IMGW . '/png/wizard1.png';

$imagick->readImage($pngfn);

$strg = $imagick->getImageBlob();

echo 
$strg;

?>

  4 EXERCISE   

<?php

$path 
= PATH2IMGW . '/others/IMG_0703.jpg';
 
$imagick = new Imagick($path);
     
$imagick->readImage($path);

$strg = $imagick->getImageBlob();

echo 
$strg;

?>

  5 EXERCISE   

<?php

$imagick 
= new Imagick();

$jpgfn = PATH2IMGW . '/jpg/aa.jpg';
$str1img = 'img/jpg/aa1.jpg';

$imagick->readImage($jpgfn);

$strg = $imagick->getImageBlob();

// Reads the STRING of getImageBlob() with the PHP GD library
$img = imagecreatefromstring($strg);

imagejpeg($img, $str1img);

echo 
basename($str1img); ?>
<br><br>The image created by the use of this STRING:
<br><br>
<img src="<?php echo $str1img; ?>"
 alt="<?php echo $str1img; ?>" 
 title="<?php echo $str1img; ?>">

 RESULT   

aa1.jpg

The image created by the use of this STRING:

img/jpg/aa1.jpg apr

  6 EXERCISE   

<?php
  
// Create a new imagick object
$imagick = new Imagick();

$pngfn = PATH2IMGW . '/gif/E 01 01.gif';
$str2img = 'img/png/E 01 01.png';

$imagick->readImage($pngfn);

$strg = $imagick->getImageBlob();

// Reads the STRING of getImageBlob() with the PHP GD library
$img = imagecreatefromstring($strg);

imagepng($img, $str2img);

echo 
basename($str2img); ?>
<br><br>The image created by the use of this STRING:
<br><br>
<img src="<?php echo $str2img; ?>"
 alt="<?php echo $str2img; ?>" 
 title="<?php echo $str2img; ?>">

E 01 01.png

The image created by the use of this STRING:

img/png/E 01 01.png apr

  7 EXERCISE   

<?php
  
// Create a new imagick object
$imagick = new Imagick();

$pngfn = PATH2IMGW . '/png/wizard.png';
$str3img = 'img/png/wizard3.png';

$imagick->readImage($pngfn);

$strg = $imagick->getImageBlob();

// Reads the STRING of getImageBlob() with the PHP GD library
$img = imagecreatefromstring($strg);

imagepng($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; ?>">

wizard3.png

The image created by the use of this STRING:

img/png/wizard3.png apr