我想使用PHP和ImageMagick对图像应用卷曲或剥离效果。
我在PHP中尝试了各种库,但只有ImageMagick可以这样做。我想要与此处相同的输出:
答案 0 :(得分:1)
在Fred Weinhaus的高级ImageMagick脚本集合中,有 pagecurl 脚本。
开箱即用,它会对IM内置wizard:
测试图像产生以下影响:
pagecurl wizard: wiz-curled.png
该脚本在右下角应用效果,但可以通过多种方式进行参数化:
pagecurl:
USAGE: pagecurl [-a amount] [-m mode] [-c color] [-b bgcolor] [-e ellipticity] [-x xcoord] [-y ycoord] [-g gcontrast] [-d dcontrast] infile [bgfile] outfile
USAGE: pagecurl [-help]
OPTIONS:
-a amount amount of pagecurl expressed as percent of image
width; integer>=0; default=50
-m mode mode of shading curl; plain, grad or doublegrad;
default=grad
-c color color to apply to curl; any valid IM color;
default=white
-b bgcolor background color to apply to image where curled away;
any valid IM color; default=none (transparent)
-e ellipticity curl flattening from circle to ellipse;
0<=float<1; default=0 for circle; recommended value
other 0 is 0.5 for ellipse shape
-x xcoord x coordinate for apex of curl;
default=right image edge
-y ycoord y coordinate for apex of curl;
default=upper image edge
-g gcontrast contrast adjustment for mode=grad; 0<=integer<=100;
increases contrast only; default=15
-d dcontrast contrast adjustment for mode=doublegrad;
-100<=integer<=100; positive increase contrast;
negative decreases contrast; default=0
NAME: PAGECURL
PURPOSE: Applies a pagecurl effect to the lower right corner of an image.
DESCRIPTION: PAGECURL Applies a pagecurl effect to the lower right corner
of an image. The apex of the curl is nominally in the upper right corner of
the image, but can be adjusted. The curl is always right to left. The curl
can be shaded and/or colored. The removed area can be colored, transparent
or filled with an optional same size background image if provided. Note
that this is a 2D simulation and not a true 3D effect.
OPTIONS:
-a amount ... AMOUNT of pagecurl expressed as percent of image width.
Values are in range integer>=0. The default=50.
Caution: values below about 5 may fail.
-m mode ... MODE shading on the curl.
Choices are: plain (or p), grad (or g) for gradient, or
doublegrad (or d) for double gradient. Default=grad.
-c color ... COLOR is the color to apply to curl.
Any valid IM color is allowed. The default=white.
-b bgcolor ... BGCOLOR is the color to apply to curled away part of the image.
Any valid IM color is allowed. The default=none for transparent.
If a background file is provided, bgcolor must be none.
-e ellipticity ... ELLIPTICITY is the amount of curl flattening from a circle
to an ellipse.
Values are in range 0<=float<1. The default=0 for circle.
Recommended value other 0 is 0.5 for ellipse shape.
-x xcoord ... XCOORD is the X coordinate for the apex of the curl.
Values are 0<integers<width.
The default is the right edge of the image.
-y ycoord ... YCOORD is the Y coordinate for the apex of the curl.
Values are integers.
The default is the upper edge of the image.
-g gcontrast ... GCONTRAST is the contrast adjustment for mode=grad.
Values are in range 0<=integer<=100.
This increases contrast only. The default=15
-d dcontrast ... DCONTRAST is the contrast adjustment for mode=doublegrad.
Values are in range -100<=integer<=100.
Positive values increase contrast.
Negative values decrease contrast. The default=0
Thanks to Anthony Thyssen for critiqing the original version and for
several useful suggestions for improvement.
CAVEAT: No guarantee that this script will work on all platforms,
nor that trapping of inconsistent parameters is complete and
foolproof. Use At Your Own Risk.
要获得右上角的卷曲效果,您可以执行以下操作:
convert wizard: -flip -frame 1 miff:- \
| pagecurl -a 15 -m grad -e 0.5 -y 510 -x 479 -c lightgray -g 33 - miff:- \
| convert - -flip curl2.png
convert wizard: -flip -frame 1 miff:- \
| pagecurl -a 20 -m grad -e 0.7 -y 490 -x 479 -c lightgray -g 5 - miff:- \
| convert - -flip curl3.png
然后结果如下:
答案 1 :(得分:0)
我会使用叠加图像(可能是带有alpha的PNG)来应用此效果 - 这可以使用ImageMagick或在渲染层(例如HTML / CSS等)中完成
对于PHP / Imagick扩展,Imagick::mergeImageLayers
方法可能很有用。