yiisoft / yii2-imagine

Yii 2 imagine extension
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
287 stars 94 forks source link

Ignore `OutOfBoundsException` error when watermark grower of source image #51

Open yii-bot opened 6 years ago

yii-bot commented 6 years ago

This issue has originally been reported by @NabiKAZ at https://github.com/yiisoft/yii2/issues/16612. Moved here by @samdark.


When use this command:

Image::watermark('image.jpg', 'watermark.jpg')->save('image.jpg');

If dimension of watermark, grower of source image, return this error:

Exception 'Imagine\Exception\OutOfBoundsException' with message 'Cannot paste image of the given size at the specified position, as it moves outside of the current image's box' 

It's fine. But how can ignore this error, so new image will be create but the part of watermark that outside of the image box is hidden and removed.

rob006 commented 6 years ago

Related: https://stackoverflow.com/questions/51698580/ignore-outofboundsexception-error-when-watermark-grower-of-source-image

This could be fixed by automatically cropping/resizing watermark in such cases.