Code: Select all
<?php
/*********************************** Make a nifty label ************************************/
   $report= "<html><body style= \"margin:5%; font-size:12pt\">\n\n";
    $report .= "<p style=\"color:blue; text-align:center\">PHP Imagick Image Library Label Test</p>\n\n";
/* This is the IM command version:
-size 900x85 xc:#ffffee -font Bookman-DemiItalic -pointsize 30 -draw "text 10,60 'Image created and saved: 9 Aug 2007 02:36:38 PM'" -channel RGBA -gaussian 0x6 -fill darkred -stroke magenta -draw "text 5,55 'Image created and saved: 9 Aug 2007 02:36:38 PM'"
*/
   $obj2=       new Imagick();                  //Object
   $draw=      new ImagickDraw();                //Drawing objects
   $color=    new ImagickPixel();               //Pixels color objects
   $php5= ((int)PHP_VERSION >= 5)? TRUE : FALSE;
   if($php5)date_default_timezone_set('America/New_York');                     //Set as needed, php5.1+
   $text= 'Image created and saved: ' . date('j M Y h:i A');
   $width=    940;
   $height=    85;
   $font_size=    32;
   $left_margin=   30;
   $top_margin=   55;                                       //Text and shadow location
   $label_img=   './test_label.jpg';
   $color->setColor('skyblue');
   $obj2->newImage($width, $height, $color);                           //Create the label image
   $draw->setFont("Bookman-DemiItalic");                              //Set the font
   $draw->setFontSize($font_size);                                    //Set the size
   $color->setColor("black");                                                                                              //Shadow color
   $draw->setFillColor($color);
   $obj2->annotateImage($draw, $left_margin+5, $top_margin+5, 0, $text);                //Add the text shadow
   $obj2->gaussianBlurImage(0, 6);                                 //Blur it
   $color->setColor("darkred");                                    //Text color
   $draw->setFillColor($color);
   $color->setColor('magenta');                                    //Stroke color
   $draw->setStrokeColor($color);
   $draw->annotation($left_margin, $top_margin, $text);                     //Add pretty text
   $obj2->drawImage($draw);                                 //Add the text layer
/********* 3d Frame it ********************************/
/*
* The IM command:  -mattecolor Blue -frame 10x10+0+6
*/
   $color->setColor('blue');
   $obj2->frameImage($color, 14, 14, 0, 8);
   $obj2->SetImageFormat('jpeg');
   $obj2->writeImage($label_img);
   $report .= "<img alt=\"image missing\" src=\"$label_img\">\n\n";
        $report .= "</body></html>\n\n";
        echo $report;