【问题标题】:Upload and crop image and add text from frontend in wordpress在 wordpress 中上传和裁剪图像并从前端添加文本
【发布时间】:2019-07-09 19:54:24
【问题描述】:


我的客户需要他的访问者能够上传、缩放和裁剪图像,在裁剪的图像上添加文本并选择文本的位置。
像这张图片上的例子: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】:

    您可以在 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/

    【讨论】:

      猜你喜欢
      • 2015-08-10
      • 2021-06-18
      • 2020-12-24
      • 1970-01-01
      • 1970-01-01
      • 2021-09-04
      • 2019-02-03
      • 1970-01-01
      • 2021-06-28
      相关资源
      最近更新 更多