SVG to PNG image conversion in php

不打扰是莪最后的温柔 提交于 2019-12-24 06:28:02

问题


I want to convert SVG images to PNG files with transparent background. I am using below code to convert it using imagick in php,but it gives image with black background.

        $image = new imagick();
        //set transparent background
        $image->setBackgroundColor(new ImagickPixel('transparent'));
        $image->setFormat('svg');
        $image->readImageBlob(file_get_contents("image.svg"));
        $image->setImageFormat("png32");
        $image->resizeImage(265,195, Imagick::FILTER_LANCZOS, 1);
        $image->writeImage('result.png');

Can anyone please help me how to convert above svg image to png image using PHP. Any help would be appreciated.

来源:https://stackoverflow.com/questions/39661410/svg-to-png-image-conversion-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!