php - 如何通过 PHP 对静态图像应用 pagecurl 效果

标签 php imagemagick page-curl

我想使用 PHP 和 ImageMagick 对图像应用 curl 或剥离效果。

我在 PHP 中尝试了各种库,但只有 ImageMagick 可以做同样的事情。我想要与此处相同的输出:

image with effect

最佳答案

在 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. 

要获得右上角的 curl 效果,您可以执行以下操作:

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

然后结果是这样的:

关于php - 如何通过 PHP 对静态图像应用 pagecurl 效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30588362/

相关文章:

android - 如何应用点击监听器?

ios - 添加页面 curl 层(不是动画)

javascript - 如果两个或多个请求同时出现会发生什么?

php - 在 Symfony 2.4 中获取主请求

PHP/MYSQL 并行代码/查询执行

testing - 使用图像差异的自动跨浏览器兼容性测试

ImageMagick:转换后无效的 ICC 配置文件

imagemagick - 为什么我的机器上的范围(imagemagick)行为不统一?

iPhone 页面 curl 选项

javascript - PHP 和 WooCommerce 问题