How to detect position of shape in image PHP [closed]

岁酱吖の 提交于 2019-12-02 07:30:19

You can use the trimImage function to trim the image, and then look at the geometry and page info to find how the bounding box of the image that was left after trimming.

$base = new Imagick(realpath('./trim.png'));

$base->trimImage(0);

$geometry = $base->getImageGeometry();
$pageInfo = $base->getImagePage();

printf (
    "Width %d Height %d\n",
    $geometry['width'],
    $geometry['height']
);

printf(
    "OffsetX: %d OffsetY %d\n",
    $pageInfo['x'],
    $pageInfo['y']
);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!