急!悬赏任务邀请海报出错Invalid blending. Image 2 is outside the canvas,如何解决?(语言-php)

悬赏任务邀请海报出错,求解

[0] Exception in Editor.php line 71
Invalid blending. Image 2 is outside the canvas.

代码如下:
// Position is for $image2. $image1 is canvas.
list($offsetX, $offsetY) = $position->getXY($image1->getWidth(), $image1->getHeight(), $image2->getWidth(), $image2->getHeight());

    // Check if it overlaps
    if( ($offsetX >= $image1->getWidth() ) or
        ($offsetX + $image2->getWidth() <= 0) or
        ($offsetY >= $image1->getHeight() ) or
        ($offsetY + $image2->getHeight() <= 0)){

        throw new \Exception('Invalid blending. Image 2 is outside the canvas.');
    }

    // Loop start X
    $loopStartX = 0;
    $canvasStartX = $offsetX;
    if($canvasStartX < 0){
        $diff = 0 - $canvasStartX;
        $loopStartX += $diff;
    }

Call Stack
in Editor.php line 71
at Editor->blend(object(Image), object(Image), 'normal', 0.9, object(Position), 325, 625) in MakeQrcode.php line 43
at MakeQrcode->make_haibao('/www/wwwroot/cs.shan...', './qrcode/1_qrcode.pn...', 'invite', 'invite', 6719, '325,625,110,110') in User.php line 62
at User->invite()
at ReflectionMethod->invokeArgs(object(User), []) in App.php line 343
at App::invokeMethod([object(User), 'invite'], []) in App.php line 611
at App::module(['home', 'user', 'invite'], ['app_host' => '', 'app_debug' => true, 'app_trace' => false, ...], false) in App.php line 456
at App::exec(['type' => 'module', 'module' => ['home', 'user', 'invite'], 'convert' => false], ['app_host' => '', 'app_debug' => true, 'app_trace' => false, ...]) in App.php line 139
at App::run() in start.php line 19
at require('/www/wwwroot/cs.shan...') in index.php line 17

你得php版本多少

同样的问题。你解决了吗?

这个错误是因为合成图片的第二张图超出了画布的范围,所以需要对第二张图的坐标进行调整,确保不会超出画布的范围。根据代码,这个调整发生在Editor.php的第71行。

这里的 $position 变量用于计算第二张图应该被放置在画布上的哪个位置。你需要确认一下你传递给 $position 的参数是否正确,或者尝试改变 $position 的值来避免超出画布范围的错误。具体来说,你可以调整第二个图像的位置或大小,或者使用裁剪或缩放等技术来处理超出画布的部分。