dc2.jd.com auto.php,imagecropauto

这篇博客探讨了PHP中用于智能裁剪图像的IMG_CROP_*常量,特别是如何根据背景颜色进行裁剪。它详细解释了如何通过检查像素列和行来识别并去除单一颜色背景,如透明、黑色或白色。此外,还介绍了IMG_CROP_THRESHOLD常量,允许设定颜色匹配的阈值来裁剪图像,并提到了默认行为,即尝试使用IMG_CROP_TRANSPARENT,若不成功则回退到IMG_CROP_SIDES。
摘要由CSDN通过智能技术生成

[#1]

jordie at jordie dot org [2014-08-15 16:38:06]

Found the list of IMG_CROP_* constants in the PHP source code:

Essentially this function crops the image from any padded background if the background is a single standard colour. It will look at columns of pixels first, if a whole column is the same color that's being searched for, the column (image width) will be cropped. Then the pixel rows will be analyzed and height cropped.

IMG_CROP_TRANSPARENT - crops out a transparent background

IMG_CROP_BLACK - crops out a black background

IMG_CROP_WHITE - crops out a black background

IMG_CROP_SIDES - Uses the 4 corners of the image to attempt to detect the background to crop

IMG_CROP_THRESHOLD -  Crop an image using a given color. The threshold argument defines the tolerance to be used while comparing the image color and the color to crop. The method used to calculate the color difference is based on the color distance in the RGB(a) cube.

IMG_CROP_DEFAULT - Attempts to use IMG_CROP_TRANSPARENT and if it fails it falls back to IMG_CROP_SIDES

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值