Use imagemagick on a blob image

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
mdrattitude

Use imagemagick on a blob image

Post by mdrattitude »

Hi,

i store my images in my database.
I'm able to display the image in the page using this code :

Code: Select all

header('Content-Type: image/jpeg');
    $source = imagecreatefromstring($photo['image']);
    
    $width_src = imagesx($source);
    $height_src = imagesy($source);

    $destination = imagecreatetruecolor ($width_src, $height_src) or die ("Erreur pour créer l'image");
	
    // on créé un cadre autour de la miniature
    $blanc = imagecolorallocate ($destination, 255, 255, 255);
    $gris[0] = imagecolorallocate ($destination, 69, 69, 69);
    $gris[1] = imagecolorallocate ($destination, 82, 82, 82);
    $gris[2] = imagecolorallocate ($destination, 97, 97, 97);
    $gris[3] = imagecolorallocate ($destination, 107, 107, 107);
    $gris[4] = imagecolorallocate ($destination, 120, 120, 120);
    $gris[5] = imagecolorallocate ($destination, 134, 134, 134);
    $gris[6] = imagecolorallocate ($destination, 145, 145, 145);
    
    for ($i=0; $i<7; $i++) {
       imagefilledrectangle($destination, $i, $i, $width_src-$i, $height_src-$i, $gris[$i]);
    }
	
    // créé la miniature : attention fonction lourde
	imagecopyresampled($destination, $source, 8, 8, 0, 0, $width_src-(2*8), $height_src-(2*8), $width_src, $height_src);
    
	imagejpeg($destination);
	
	
	
    imagedestroy($destination); 
and i want to use some features of imagemagick on this image.

I dont know how to do that.

i tried something like :

Code: Select all

exec('convert.exe '.$photo['image'].' image.png');

// or 

exec('convert.exe '.$destination.' image.png');
but it seems to not work :(

If someone can help me i will really appreciate it.

Thanks
Clement
Post Reply