目前我正在尝试使用 imagick 生成一些图像而不将它们保存在服务器上然后输出到浏览器,我选择的方法是带有 imagick 扩展的 php 图像魔术。我阅读了文档,并且确定该软件包已安装在我的机器上(windows xp,带有 xampp)。类已安装
imagick module enabled
imagick module version 2.0.0-alpha
imagick classes Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator
ImageMagick version ImageMagick 6.3.3 04/21/07 Q16 http://www.imagemagick.org
ImageMagick release date 04/21/07
ImageMagick Number of supported formats: 164
ImageMagick Supported formats A, ART, AVI, AVS, B, BIE, BMP, BMP2, BMP3, C, CACHE, CAPTION, CIN, CIP, CLIP, CLIPBOARD, CMYK, CMYKA, CUR, CUT, DCM, DCX, DFONT, DPS, DPX, EMF, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, FAX, FITS, FRACTAL, FTS, G, G3, GIF, GIF87, GRADIENT, GRAY, HISTOGRAM, HTM, HTML, ICB, ICO, ICON, INFO, JBG, JBIG, JNG, JP2, JPC, JPEG, JPG, JPX, K, LABEL, M, M2V, MAP, MAT, MATTE, MIFF, MNG, MONO, MPC, MPEG, MPG, MSL, MSVG, MTV, MVG, NULL, O, OTB, OTF, PAL, PALM, PAM, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PFA, PFB, PGM, PGX, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG24, PNG32, PNG8, PNM, PPM, PREVIEW, PS, PS2, PS3, PSD, PTIF, PWP, R, RAS, RGB, RGBA, RGBO, RLA, RLE, SCR, SCT, SFW, SGI, SHTML, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TILE, TIM, TTC, TTF, TXT, UIL, UYVY, VDA, VICAR, VID, VIFF, VST, WBMP, WMF, WMFWIN32, WMZ, WPG, X, XBM, XC, XCF, XPM, XV, XWD, Y, YCbCr, YCbCrA, YUV
这是来自 phpinfo 所以我知道我已经安装了它,问题是当我尝试生成图像并保存它时,它可以完美地工作,但是当我尝试直接输出图像时,我将脚本 url 作为图像
$draw = new ImagickDraw();
$draw->setFont('AnkeCalligraph.TTF');
$draw->setFontSize(52);
$draw->annotation(110, 110, "Hello World!");
$draw->annotation(50, 220, "Hello World!");
$canvas = new Imagick('./pictures/test_live.PNG');
$canvas->drawImage($draw);
$canvas->setImageFormat('png');
header("Content-Type: image/png");
echo $canvas;
这是使用的代码。如果我使用 writeimage,则服务器上的文件创建没有问题。有谁知道我做错了什么?