function addText($source_name, $string, $save_name = "", $font_height = 30, $text_align = "center", $color = "#ff0000", $font = "Arial", $Antialias = true)
 {
     $resource = NewMagickWand();
     $drw_wnd = NewDrawingWand();
     MagickReadImage($resource, $source_name);
     //MagickResizeImage( $resource, 160, 120 ,MW_BoxFilter,1);
     DrawSetFillColor($drw_wnd, $color);
     DrawSetFontSize($drw_wnd, $font_height);
     DrawSetFont($drw_wnd, $font);
     DrawSetTextAntialias($drw_wnd, $Antialias);
     $src_image_x = MagickGetImageWidth($resource);
     $src_image_y = MagickGetImageHeight($resource);
     $string_width = MagickGetStringWidth($resource, $drw_wnd, $string, FALSE);
     $string_height = MagickGetStringHeight($resource, $drw_wnd, $string, FALSE);
     switch ($text_align) {
         case "center":
             $text_x = $src_image_x / 2 - $string_width / 2;
             $text_y = $src_image_y / 2 - $string_height / 2;
             break;
         default:
             break;
     }
     DrawAnnotation($drw_wnd, $text_x, $text_y, $string);
     MagickDrawImage($resource, $drw_wnd);
     if ($save_name) {
         MagickWriteImage($resource, $save_name);
     } else {
         header('Content-Type: image/jpeg');
         MagickEchoImageBlob($resource);
     }
     DestroyDrawingWand($drw_wnd);
     DestroymagickWand($resource);
 }
Esempio n. 2
0
 public function destoryWand()
 {
     $numargs = func_num_args();
     $arg_list = func_get_args();
     for ($i = 0; $i < $numargs; $i++) {
         switch (true) {
             case IsMagickWand($arg_list[$i]):
                 DestroyMagickWand($arg_list[$i]);
                 break;
             case IsDrawingWand($arg_list[$i]):
                 DestroyDrawingWand($arg_list[$i]);
                 break;
             case IsPixelWand($arg_list[$i]):
                 DestroyPixelWand($arg_list[$i]);
                 break;
             case IsPixelIterator($arg_list[$i]):
                 DestroyPixelIterator($arg_list[$i]);
                 break;
             default:
                 break;
         }
     }
     return;
 }
Esempio n. 3
0
        break;
    }
    $font_size--;
}
$pre_morph_wnd =& checkWandError(MagickGetImage($mgck_wnd), $mgck_wnd, __LINE__);
addText($txt_wnd, $white, $font_size, $logo);
drawNewImage($pre_morph_wnd, $txt_wnd, $width, $height, $bg_color, __LINE__);
ClearDrawingWand($txt_wnd);
addText($txt_wnd, $white, $font_size, $welcome_msg);
drawNewImage($pre_morph_wnd, $txt_wnd, $width, $height, $bg_color, __LINE__);
MagickSetFirstIterator($mgck_wnd);
checkWandError(MagickAddImage($pre_morph_wnd, $mgck_wnd), $pre_morph_wnd, __LINE__);
addMorphedImages($mgck_wnd, $pre_morph_wnd, $num_morph_frames, $morph_delay, __LINE__);
DestroymagickWand($pre_morph_wnd);
DestroyDrawingWand($drw_wnd);
DestroyDrawingWand($txt_wnd);
checkWandError(MagickSetFormat($mgck_wnd, 'GIF'), $mgck_wnd, __LINE__);
header('Content-Type: ' . MagickGetMimeType($mgck_wnd));
MagickEchoImagesBlob($mgck_wnd);
DestroymagickWand($mgck_wnd);
/* ********** Function Declarations ********** */
/**
 * Function checkWandError() compares the value of $result, which should be
 * the result of any MagickWand API function, to explicit FALSE, and if it is
 * FALSE, checks if $wand for contains an error condition (in case the API
 * function is just returning FALSE as a normal return value).
 *
 * If the return value is FALSE, and the $wand contains a set error condition,
 * the function outputs the error and forcibly ends the program.
 *
 * If not, returns $result as a reference.