Pregunta

I've a problem with Imagick - PHP. I've this code :

function createImages ($src, $dst, $width, $height)
{
        $image = new Imagick($src);
        $image->stripImage();

        $color = new ImagickPixel();
        $color->setColor('rgb(255,255,255)');
        if(resizeimage($image, $width, $height)) {
            $image->borderimage($color, 
            intval(($width - $image->getimagewidth()) / 2), 
            intval(($height - $image->getimageheight()) / 2));
            $image1 = new Imagick();
            $image1->newImage($width, $height, new ImagickPixel('white'));
            $image1->setImageColorspace($image->getImageColorspace());
            $image1->compositeImage($image, $image1->getImageCompose(), 0, 0);
            $image1->setImageCompressionQuality(90);
            $image1->setimagecompression(Imagick::COMPRESSION_JPEG);
            $image1->setformat('jpeg');
            $fileHandle = fopen($dst, "w");
            $image1->writeImageFile($fileHandle);
            $color->destroy();
            $image1->destroy();
        }           
        $image->destroy();
        return true;
}

And this error :

Fatal error: Call to undefined method Imagick::writeImageFile()

I don't understand why all other methods work good, but not writeImageFile(). Can you help me please?

¿Fue útil?

Solución

The writeImageFile function is available in ImageMagick version 6.3.6, so perhaps your version is not recent enough? There is also writeImage which may be a usable alternative in your case: http://www.php.net/manual/en/imagick.writeimage.php

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top