示例#1
0
 public function generateImg($img, $desFile = "")
 {
     MagickCommentImage($img, "Image Creator (MagickWand) By Windy2000");
     $type = MagickGetImageFormat($img);
     $frame_count = MagickGetNumberImages($img);
     if (empty($type)) {
         $type = $frame_count > 1 ? "GIF" : "JPG";
     }
     if (strpos("tile,gradient,caption,label,logo,netscape,rose", strtolower($type)) !== false) {
         $type = "PNG";
     }
     MagickSetFormat($img, $type);
     if (empty($desFile)) {
         //header("Content-Type: ".MagickGetMimeType($img));
         if ($frame_count > 1) {
             MagickEchoImagesBlob($img);
         } else {
             MagickEchoImageBlob($img);
         }
     } else {
         if ($frame_count > 1) {
             MagickWriteImages($img, $desFile, MagickTrue);
         } else {
             MagickWriteImage($img, $desFile);
         }
     }
     if (WandHasException($img)) {
         $this->Error($img);
     }
     $result = MagickGetExceptionType($img);
     DestroyMagickWand($img);
     return $result;
 }
示例#2
0
}
$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.
 *
 * @param mixed       MagickWand API function result
 * @param resource    Any MagickWand API resource