private function getLibraryInstance($library)
    {
        switch ($library) {
            case 'gd':
                return new \Imagine\Gd\Imagine();
                break;

            case 'imagick':
                return new \Imagine\Imagick\Imagine();
                break;

            case 'gmagick':
                return new \Imagine\Gmagick\Imagine();
                break;

            default:
                throw new ImagineException('Unsupported image library "' . $library . '". Cannot create Imagine instance.'
                );
                break;
        }
    }