コード例 #1
0
 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);
 }
コード例 #2
0
ファイル: demo.php プロジェクト: nateirwin/custom-historic
    $y2 -= $y_int;
    drawNewImageSetDelay($mgck_wnd, $drw_wnd, $width, $height, $bg_color, $cnt_down_delay, __LINE__);
    addText($txt_wnd, $white, $font_size, $i);
    checkWandError(MagickDrawImage($mgck_wnd, $txt_wnd), $mgck_wnd, __LINE__);
    ClearDrawingWand($txt_wnd);
}
addText($drw_wnd, $white, $font_size, $i);
drawNewImageSetDelay($mgck_wnd, $drw_wnd, $width, $height, $bg_color, $swirl_delay, __LINE__);
for ($swirl_deg = $swirl_deg_start; $swirl_deg <= $swirl_deg_end; $swirl_deg += $swirl_deg_int) {
    drawNewImageSetDelay($mgck_wnd, $drw_wnd, $width, $height, $bg_color, $swirl_delay, __LINE__);
    checkWandError(MagickSwirlImage($mgck_wnd, $swirl_deg), $mgck_wnd, __LINE__);
}
while (TRUE) {
    DrawSetFontSize($txt_wnd, $font_size);
    $logo_width =& checkWandError(MagickGetStringWidth($mgck_wnd, $txt_wnd, $logo), $mgck_wnd, __LINE__);
    $welcome_msg_width =& checkWandError(MagickGetStringWidth($mgck_wnd, $txt_wnd, $welcome_msg), $mgck_wnd, __LINE__);
    if ($logo_width < $width && $welcome_msg_width < $width) {
        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);