上传和裁剪图片,并在wordpress的前端添加文本

问题描述 投票:0回答:1

我的客户需要他的访问者能够上传,缩放和裁剪图像,在裁剪的图像上添加文本并选择文本的位置。 像这个图像的例子:http://devadesign.biz/example.jpg 单击“提交”按钮后,包含文本的裁剪图像必须保存在特定文件夹中。 是否有类似的插件或教程?

我已经尝试了一些像这样的插件和脚本: https://artisansweb.net/upload-crop-resize-image-using-jquery-php/ https://www.sanwebe.com/2012/05/ajax-image-upload-and-resize-with-jquery-and-php https://www.sitepoint.com/crop-and-resize-images-with-imagemagick/ http://www.croppic.net/ https://foliotek.github.io/Croppie/ ...但它们都不支持添加文本。 谢谢!

image text crop
1个回答
0
投票

你可以在Imagemagick中做到这一点。这是一个例子:

输入:

enter image description here

line 1: read input and put into memory and delete input
line 2: add contast to memory input
line 3-5: add white to memory input
line 6-7: create a white image with a black rectangle in the middle as a mask
line 8: composite the two modified input images using the mask
line 9: set up the fill and stroke for creating a black outline around the middle
line 10: draw the black polygon rectangle
line 11: set up the pointsize and colors for the text
line 12: draw the text with annotate
line 13: save the output

convert lena.jpg -write mpr:img +delete \
\( mpr:img -level 10x100% \) \
\( mpr:img -alpha set \
-channel a -evaluate set 80% +channel \
-background white -flatten \) \
\( -clone 0 -fill white -colorize 100 \
-fill black -draw "rectangle 64,64 192,192" -alpha off \) \
-compose over -composite \
-fill none -stroke black \
-draw "polygon 64,64 192,64 192,192 64,192" -alpha off \
-gravity center -pointsize 24 -fill white -stroke white \
-annotate +0+0 "TESTING" \
result.png

enter image description here

有关绘图选项,请参阅https://imagemagick.org/Usage/draw

Wordpress有一个Imagemagick插件。见https://wordpress.org/plugins/tags/imagemagick/

© www.soinside.com 2019 - 2024. All rights reserved.