yii\imagine\BaseImage::ensureImageInterfaceInstance PHP Method

ensureImageInterfaceInstance() protected static method

Takes either file path or ImageInterface. In case of file path, creates an instance of ImageInterface from it.
Since: 2.1.0
protected static ensureImageInterfaceInstance ( string | resource | Imagine\Image\ImageInterface $image ) : Imagine\Image\ImageInterface
$image string | resource | Imagine\Image\ImageInterface
return Imagine\Image\ImageInterface
    protected static function ensureImageInterfaceInstance($image)
    {
        if ($image instanceof ImageInterface) {
            return $image;
        }
        if (is_resource($image)) {
            return static::getImagine()->read($image);
        }
        if (is_string($image)) {
            return static::getImagine()->open(Yii::getAlias($image));
        }
        throw new InvalidParamException('File should be either ImageInterface, resource or a string containing file path.');
    }