tim*_*ton 18
这应该是一个简单的替代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;
}
Run Code Online (Sandbox Code Playgroud)
用法:
$img = mycrop($img, ['x' => 10, 'y' => 10, 'width' => 100, 'height' => 100]);
Run Code Online (Sandbox Code Playgroud)
请注意,该错误显然已在PHP 5.6.12中修复.