使用 javascript 或 jquery 即时将文本转换为图像
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8292474/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Text to image on fly with javascript or jquery
提问by Morteza
Is there any way or method to convert text (string) to image with javascript or jquery? I cant find any way to do this. Whats the best?
有什么方法或方法可以使用 javascript 或 jquery 将文本(字符串)转换为图像?我找不到任何方法来做到这一点。什么是最好的?
I don't want to use php or asp.net to do this. Thanks for any tricks and help.
我不想使用 php 或 asp.net 来做到这一点。感谢您的任何技巧和帮助。
采纳答案by alex
回答by wargodz009
creating image from string with php
用php从字符串创建图像
<?php
// Create a 100*30 image
$im = imagecreate(100, 30);
// White background and blue text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);
// Write the string at the top left
imagestring($im, 5, 0, 0, 'Hello world!', $textcolor);
// Output the image
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
more info here
更多信息在这里