一个出于好奇心的简单问题,可能有一个复杂的答案:是否可以通过组合其他 GD 函数来模拟早期版本(如 5.4)中的新 PHP 5.5 imagecrop() ?
嗯..但是没有 imagecrop()黑线虫子, 请。 :p
这应该是一个简单的替代品imagecrop()
(没有错误...):
function mycrop($src, array $rect)
{
$dest = imagecreatetruecolor($rect['width'], $rect['height']);
imagecopy(
$dest,
$src,
0,
0,
$rect['x'],
$rect['y'],
$rect['width'],
$rect['height']
);
return $dest;
}
Usage:
$img = mycrop($img, ['x' => 10, 'y' => 10, 'width' => 100, 'height' => 100]);
请注意,该错误显然已修复PHP 5.6.12.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)