首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用javascript或jquery将文本转换为动态图像

使用javascript或jquery将文本转换为动态图像
EN

Stack Overflow用户
提问于 2011-11-28 15:05:46
回答 2查看 16.2K关注 0票数 16

有没有什么方法可以用javascript或jquery将文本(字符串)转换成图像?我找不到任何方法来做这件事。最好的是什么?

我不想使用php或asp.net来做这件事。感谢你的任何技巧和帮助。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-11-28 15:09:20

使用canvas元素和draw text onto it

jsFiddle

票数 15
EN

Stack Overflow用户

发布于 2011-11-28 15:33:53

用php从字符串创建图像

代码语言:javascript
复制
 <?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);
 ?>

更多信息here

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8292474

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档