currently i'm trying to use imagick to generate some images without saving them on the server and then outputting to the browser, my method of choice was image magic with the imagick extension for php. I read the documentation, and i'm sure the package is installed on my machine (windows xp, with xampp). the class is installed
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
this is from the phpinfo so i know i have it installed, the thing is when i try to generate an image and save it, it works flawlessly, but when i try to output the image directly, i get the script url as an image
$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;
this is the code used. if i use writeimage, then the file on the server is created with no problems. does anyone have any ideas what i'm doing wrong ?
The browser (typically, Firefox does that) displaying the URL instead of the content of the image is often caused by an invalid image -- i.e. when sending HTTP headers that say to the browser the content should be interpreted as an image, but the content cannot be interpreted as an image.
If your code is building the image properly when writting it to a file, the problem you have might be caused by sending output that doesn't belong to the image.
Make sure you don't have any other output than the image -- not even a white-space before or after the PHP tags.
found the solution... instead of echo $canvas;
using echo $canvas->getImageBlob();
works perfectly
精彩评论