在 wordpress 中上传和裁剪图像并从前端添加文本

Upload and crop image and add text from frontend in wordpress


我的客户需要他的访问者能够上传、缩放和裁剪图像,在裁剪图像上添加文本并选择文本的位置。
类似于此图片上的示例: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/
...但其中 none 支持添加文本。
谢谢!

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

输入:

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


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

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