- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
以下 JavaScript 代码会将 SVG 字符串转换为图像 blob,然后可用于在浏览器中显示:
var data = '<svg xmlns="http://www.w3.org/2000/svg" width="390" height="65">' +
'<rect x="0" y="0" width="100%" height="100%" fill="#7890A7" stroke-width="20" stroke="#ffffff" ></rect>' +
'<foreignObject x="15" y="10" width="100%" height="100%">' +
'<div xmlns="http://www.w3.org/1999/xhtml" style="font-size:40px">' +
' <em>I</em> am' +
'<span style="color:white; text-shadow:0 0 20px #000000;">' +
' HTML in SVG!</span>' +
'</div>' +
'</foreignObject>' +
'</svg>';
var DOMURL = window.URL || window.webkitURL || window;
var img = new Image();
var svg = new Blob([data], {type: 'image/svg+xml;charset=utf-8'});
var url = DOMURL.createObjectURL(svg);
问题是我希望能够在 PHP 中做同样的事情。我考虑过使用 imagecreatefromstring 函数。这是正确的做法吗?
最佳答案
来自 imagecreatefromstring
的 PHP 手册 ( http://php.net/manual/en/function.imagecreatefromstring.php )
imagecreatefromstring() returns an image identifier representing the image obtained from the given image. These types will be automatically detected if your build of PHP supports them: JPEG, PNG, GIF, WBMP, and GD2.
SVG 没有出现在链接页面的任何位置。
关于javascript - PHP 使用 imagecreatefromstring 将 SVG 字符串转换为图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33207471/
尝试在 wordpress 管理界面中上传时,我收到主题中提到的错误。 我的服务器使用 php-fpm 运行 nginx,PHP 版本是 5.3.0。 我在谷歌上搜索了很多关于这个问题的信息,但我找不
我在 PHP 中调整图像大小时遇到问题;似乎从我使用 imagecreatefromstring 或 imagecreatefrompng 加载图像的那一刻起,颜色就会改变并褪色。 我知道我必须使
这段代码有什么问题? 我收到这些错误: 警告:imagecreatefromstring():gd-png:致命的 libpng 错误:读取错误:第 5 行 D:\wamp\www\img\inde
最好的使用方法是什么imagecreatefromstring()或 .bmp 的替代方法文件? 这样: $data = file_get_contents($path); $image = imag
我一直在努力让我的应用程序变得透明(它在存储图像之前动态调整图像大小),我认为在对 imagealphablending 和 imagesavealpha。源图像从未以适当的透明度加载! // Wit
通常我使用 imagecreatefromjpeg() 然后使用 getimagesize(),但是对于 Firefox 3 我需要绕过这个不同。所以现在我正在使用 imagecreatefromst
假设我的代码看起来像这样: "; // // more stuff here // ?> 我要替换什么/* 这里是什么? */这样我的图像数据就会显示出来? 谢谢。 最佳答案 What do I re
这是我的代码: $data = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl' . 'BMVEUAAAD///+l2Z/dAAA
我正在使用 imagecreatefromstring,目前正在验证正确的图像文件格式。 所以一个链接: swqkdwfibqwfwf 不会工作,因为它不是有效的文件类型。但我刚刚发现了这一点: si
我正在使用 imagecreatefromstring,目前正在验证正确的图像文件格式。 所以一个链接: swqkdwfibqwfwf 不会工作,因为它不是有效的文件类型。但我刚刚发现了这一点: si
我正在使用axios通过ajax发送base64字符串。使用下面的方法,当它从 Base64 数据编码回 jpg 时,我会以某种方式丢失大量数据。我怎样才能在不丢失数据的情况下发送此信息? 我从输入中
以下是我获取图片的方式: $coverurl = 'https://api.someurl/api/v1/img/' . $somenumber . '/l'; //$iheaders contai
我在 Javascript 和 PHP 之间以字符串形式发送图像时遇到问题。到目前为止,我有: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAA
我有一个简单的服务,它使用通过 URL 传递的参数生成任何文本的 PNG 图像。参数之一是文本本身,其余参数是“字体”、“颜色”、“字体粗细”等。 这种 URL 的一个例子是: http://pics
有没有办法使用 imagecreatefromstring() 并以某种方式获取图像类型? 最佳答案 当您使用 imagecreatefrom... 方法时,图像将作为未压缩的位图加载到内存中。此时并
我正在尝试从我无法控制的外部站点加载图像。 大多数时候它工作正常(到目前为止测试了数百张图像)。 它现在给我一个特定图像的错误: imagecreatefromstring():gd-jpeg、lib
目前,如果用户将照片发布/上传到我的 PHP 脚本,我会从这样的代码开始 getimagesize($_FILES['picture1']['tmp_name']); 然后我对它做了更多的事情,但我也
我创建了一个脚本,其中我必须在运行时使用 64 位编码的字符串创建图像。我使用 PHP 的 imagecreatefromstring 函数,但它在我的基于 Windows XAMPP 的 PHP 中
以下 JavaScript 代码会将 SVG 字符串转换为图像 blob,然后可用于在浏览器中显示: var data = '' + '' + '' +
当我尝试在不正确的 png 图像上使用 php-gd 函数时,出现致命的 PHP 错误。这似乎是某种错误,因为根据函数文档(例如 imagecreatefrompng): * @return reso
我是一名优秀的程序员,十分优秀!