使用PHP将JPG/PNG转换为SVG格式 [英] Convert JPG/PNG to SVG format using PHP

查看:925
本文介绍了使用PHP将JPG/PNG转换为SVG格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用PHP将JPG/PNG转换为SVG?

How do I convert JPG/PNG to SVG using PHP?

我知道它不会被矢量化,但是我需要使用SVG格式.

I know that it will not be vectorised, but I need it in a SVG-format.

除了PHP,我不想使用其他任何软件.

I dont want to use any other software than PHP.

类似这样的东西:

<?php

$image_to_cenvert = 'image.jpg';

$content = file_get_contents($image_to_cenvert);

$svg_file = fopen('image.svg','w+');

fputs($svg_file,$content);
fclose($svg_file);

?>

推荐答案

据我所知,实现此目标的唯一机会是使用imagick库,但可用格式取决于设置,因此如果您位于共享服务器上,则无法可以做到.

As i know your only chance to achieve that is to use imagick library but the format available depend on the settings so if you're on a shared server could not be possible do it.

http://php.net/manual/en/book.imagick.php

在这里: 使用PHP将SVG图像转换为PNG

and here : Convert SVG image to PNG with PHP

您可以找到有关如何将SVG图像转换为png的示例,因为imagick库具有创建和操作svg文件的可能性,以适应链接中的脚本,所以您需要做的...

you can find an example on how to convert a SVG image to png, what you will need to do is given the oossibility of your imagick library to create and manipulate svg file adapt the script in the link over...

这篇关于使用PHP将JPG/PNG转换为SVG格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆