0

我只是在学习imagick,只是想看到它起作用。我的基本用法是创建缩略图和渲染 .ai 和 .psd 文件。

我的 phpinfo() 显示已安装 imagemagick。

我有从http://valokuva.org/?cat=1获得的这段代码:

    /* Create new object */
$im = new Imagick();

/* Create new checkerboard pattern */
$im->newPseudoImage(100, 100, "pattern:checkerboard");

/* Set the image format to png */
$im->setImageFormat('png');

/* Fill background area with transparent */
$im->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);

/* Activate matte */
$im->setImageMatte(true);

/* Control points for the distortion */
$controlPoints = array( 10, 10,
                        10, 5,

                        10, $im->getImageHeight() - 20,
                        10, $im->getImageHeight() - 5,

                        $im->getImageWidth() - 10, 10,
                        $im->getImageWidth() - 10, 20,

                        $im->getImageWidth() - 10, $im->getImageHeight() - 10,
                        $im->getImageWidth() - 10, $im->getImageHeight() - 30);

/* Perform the distortion */ 
$im->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, true);

/* Ouput the image */   
//header("Content-Type: image/png");
echo $im;

现在代码只是在屏幕上打印字符,例如:

�PNG IHDRo�*��ybKGD����9�oFFs��������^�� pHYsHHF�k>3CIDATx���w�U���̽[�H!����л (�BQ@�(E� ���" J�NQA�4)�{�=�R�e˽3�Ϭ$!�l�%�o~��Mٝ{��y���� ���d��^'��I&7��}f���[��(�,����]lЍ����<�*Cog�&��������L� ��������d'L��a'���<��<�;C`Fa.䗋</p>

如果我取消对倒数第二行的注释,它只会将我带到一个损坏的图像。

我需要做点别的吗?也许解码和保存文件?也许我做错了。

4

1 回答 1

0

仔细检查您的 php 文件不包含BOM

于 2015-10-08T17:35:09.027 回答