sjaakp / yii2-illustrated-behavior

Adds image to ActiveRecord
http://www.sjaakpriester.nl/software/illustrated
MIT License
43 stars 17 forks source link

Negative y value resulting in exception #22

Open dfuse-dev opened 7 years ago

dfuse-dev commented 7 years ago

Hi, when uploading attached image

1464255380_11

it crashes with below debug info. Any advice on how to fix this?

Thanks

exception 'Imagine\Exception\InvalidArgumentException' with message 'A coordinate cannot be positioned outside of a bounding box' in .../vendor/imagine/imagine/lib/Imagine/Image/Point.php:42 Stack trace:

0 .../vendor/sjaakp/yii2-illustrated-behavior/Illustration.php(146): Imagine\Image\Point->__construct(100, -1.1165101928418E-13)

1 .../vendor/sjaakp/yii2-illustrated-behavior/Illustrated.php(202): sjaakp\illustrated\Illustration->beforeValidate(Object(yii\base\ModelEvent))

2 [internal function]: sjaakp\illustrated\Illustrated->beforeValidate(Object(yii\base\ModelEvent))

3 .../vendor/yiisoft/yii2/base/Component.php(545): call_user_func(Array, Object(yii\base\ModelEvent))

4 .../vendor/yiisoft/yii2/base/Model.php(376): yii\base\Component->trigger('beforeValidate', Object(yii\base\ModelEvent))

5 .../vendor/yiisoft/yii2/base/Model.php(343): yii\base\Model->beforeValidate()

6 .../backend/controllers/TalentsController.php(139): yii\base\Model->validate()

7 [internal function]: backend\controllers\TalentsController->actionCreate()

8 .../vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)

9 .../vendor/yiisoft/yii2/base/Controller.php(156): yii\base\InlineAction->runWithParams(Array)

10 .../vendor/yiisoft/yii2/base/Module.php(523): yii\base\Controller->runAction('create', Array)

11 .../vendor/yiisoft/yii2/web/Application.php(102): yii\base\Module->runAction('talents/create', Array)

12 .../vendor/yiisoft/yii2/base/Application.php(380): yii\web\Application->handleRequest(Object(yii\web\Request))

13 .../backend/web/index.php(18): yii\base\Application->run()

14 {main}

dfuse-dev commented 7 years ago

Seems that this is from Imagine extension. Just modified file vendor/imagine/imagine/lib/Imagine/Image/Point.php

constructor with

public function __construct($x, $y)
{
    /*if ($x < 0 || $y < 0) {
        throw new InvalidArgumentException(
            'A coordinate cannot be positioned outside of a bounding box'
        );
    }*/

    $this->x = ($x < 0 ? 0 : $x);
    $this->y = ($y < 0 ? 0 : $y);
}