creating image on the fly question

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

I have used the following PHP to read, annotate and output an image...

Code: Select all

<?
  header('Content-Type: image/gif');
  system("convert -pointsize 72 -font Utopia-Italic \\
             label:' - Font Test - ' gif:-");
?>
just expand it to do what you want.
If you are using PHP MagickWand you can use...

Code: Select all

<?
// This is a test of the Raw MagickWand installation in PHP
//   See  http://www.ioncannon.net/php/61/php-imagemagick-magickwand-examples/

$image = NewMagickWand();
if( MagickReadImage( $image, 'image.png' ) ) {
  header( 'Content-Type: image/jpeg' );
  MagickSetImageFormat( $image, 'JPEG' );
  MagickEchoImageBlob( $image );
} else {
  echo "Error in MagickReadImage()";
  echo MagickGetExceptionString($image);
}
?>
If you are using PHP imagick PECL module you can do...

Code: Select all

<?
$handle = imagick_readimage( getcwd() . "/image.gif" ) ;
if ( imagick_iserror( $handle ) )
        {
                $reason      = imagick_failedreason( $handle ) ;
                $description = imagick_faileddescription( $handle ) ;

                print "handle2 failed!<BR>\nReason: $reason<BR>\nDescription: $d
escription<BR>\n" ;
                exit ;
        } 
       $new_handle = imagick_getimagefromlist( $handle ) ;
        header( "Content-type: " . imagick_getmimetype( $new_handle ) ) ;
        print imagick_image2blob( $new_handle ) ;
?>
These are just some basic test scripts I wrote for testing a new PHP web module, which allows all three methods.
See also IM Examples, Feedback
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply