有人知道有没有jquery插件可以在图像上写文本,并让用户将其放置在图像内的任何位置

does any one know is there any jquery plugin for writing text over an image and let the user to place it on any location inside the image?

本文关键字:图像 用户 任何 位置 有没有 jquery 插件 文本      更新时间:2023-09-26

我正在寻找可以帮助您在图像上放置文本/形状的jquery或js库。喜欢这个网站http://picfont.com/它可以让您通过拖放将文本放在图像上的任何位置。

提前感谢

答案取决于您是否希望生成的文本嵌入到图像中(即像素),以便将整个图像(包括文本)保存为文件,或者您是否希望文本漂浮在图像上方。

在后一种情况下,只需使用可以绝对位于<img>元素顶部的<div>

在前一种情况下,我所知道的唯一选项是使用HTML5<canvas>元素,然后使用.fillText()将文本写入画布:

var canvas = document.getElementById('canvas'),
    ctx = canvas.getContext('2d'),
    img = new Image;
img.onload = function() {
    canvas.width = this.width;
    canvas.height = this.height;
    ctx.drawImage(this, 0, 0);
    ctx.font = "36pt Verdana";
    ctx.fillStyle = "black";
    ctx.fillText("Test Text", 42, 82);
    ctx.fillStyle = "white";
    ctx.fillText("Test Text", 40, 80);
};
img.src = ...;

另请参阅http://jsfiddle.net/D8ZZS/2/对于使用HTML5 FileReader接口从CCD_。

我之前说过,谷歌是任何知道使用搜索引擎的人最好的朋友:)

在这个网站上,你会看到30个jquery插件,它们允许你在图像上放置文本。

或使用CSS:http://css-tricks.com/text-blocks-over-image/