2015-06-02 49 views

回答

0

我会用一个叠加图像(可能是阿尔法PNG)应用此效果 - 可以这样做无论是使用ImageMagick或者在渲染层(如HTML/CSS等)

对于PHP/Imagick扩展,Imagick::mergeImageLayers方法可能很有用。

+0

最后我得到了ImageMagick的libray使用-flatten命令解决 –

0

在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 

那么结果是这样的:

 

+0

感谢库尔特Pfeifle的答案,但我想在PHP核心的例子。它是基于Linux的命令和工作,但我需要基于WAMP的服务器。 –

+0

你原来的问题中没有提到WAMP和Windows。命令行可以很容易地转换为在PHP中重用。要将他的'pagecurl' shell脚本转换为Windows .bat文件更具挑战性,但也可以完成。 –

+0

要使脚本将卷曲放在右上角,请首先垂直翻转图像。然后运行脚本。然后垂直翻转输出。如果您拥有Cygwin或Windows 10 unix等unix环境,该脚本可以在Windows上运行。 – fmw42