Generates images from uploaded image using Imagable component

@param $type
@return mixed
559372
private function generateImages($type) {
        $imagable = \Yii::$app->shop_imagable;

        $nameFile = (new Security())->generateRandomString();
        $this->$type->saveAs($imagable->imagesPath . '/' . $nameFile . '.' . $this->$type->extension);
        $image_name = $imagable->create('shop-category/' . $type,
            $imagable->imagesPath . '/' . $nameFile . '.' . $this->$type->extension);
        unlink($imagable->imagesPath . '/' . $nameFile . '.' . $this->$type->extension);

        return $image_name;
    }
1085274
public function thumbnail($type)
    {
        // We take image from posts field
        $image = $this->attributes['image'];
        // We need to get extension type ( .jpeg , .png ...)
        $ext = pathinfo($image, PATHINFO_EXTENSION);
        // We remove extension from file name so we can append thumbnail type
        $name = rtrim($image, '.'.$ext);
        // We merge original name + type + extension
        return $name.'-'.$type.'.'.$ext;
    }
475951
public function getIndex($type = null)
	{
		$container = Input::get('c');
		$files = Input::get('files', '');
		
		if (empty($type) || !in_array($type, array('style', 'script'))) {
			App::abort(404);
		}
		
		if (empty($container)) {
			App::abort(404);
		}
		
		$files = json_decode(base64_decode($files), true);
		if (empty($files) || !is_array($files)) {
			App::abort(404);
		}
		
		foreach ($files as $file) {
			Facades\Casset::container($container)->add(
				array_get($file, 'source'),
				array(),
				array_get($file, 'dependencies', array())
			);
		}
		
		$response = Response::make(Facades\Casset::container($container)->content($type));
		
		if ('style' == $type) {
			$response->headers->set('Content-Type', 'text/css');
		}
		else {
			
			$response->headers->set('Content-Type', 'application/json');
		}
		
		return $response;
	}
1357928
public function getAPIByType($type)
    {
        switch ($type) {
            case 'news_image':
                $api = self::API_NEWS_IMAGE_UPLOAD;
                break;
            default:
                $api = self::API_UPLOAD;
        }

        return $api;
    }
363794
public function create($type)
    {
        switch ($type) {
            case self::AUDIO:
                return new Type\Audio();
            case self::IMAGE:
                return new Type\Image();
            case self::GENERAL:
                return new Type\General();
            case self::VIDEO:
                return new Type\Video();
            case self::SUBTITLE:
                return new Type\Subtitle();
            case self::MENU:
                return new Type\Menu();
            case self::OTHER:
                return new Type\Other();
            default:
                throw new UnknownTrackTypeException($type);
        }
    }
156752
public static function getClass($type)
    {
        if (!static::isAvailable($type)) {
            throw new \Exception(
                "Invalid image format '{$type}'. " .
                "Allowed formats are: " . implode(', ', static::available())
            );
        }

        $className = static::$typesMap[strtolower($type)];

        return new $className();
    }
1160186
public function render_child_type( $type ) {

		$output = null;
		if ( ! empty( $this->child ) ) {
			foreach ( $this->child as $child ) {
				if ( $type === $child->type ) {
					$output .= $child->render();
				}
			}
		}

		return $output;

	}
459052
public function resize(
        ImageInterface $image,
        $height,
        $width,
        $type = ElcodiMediaImageResizeTypes::FORCE_MEASURES
    ) {
        $imageData = $this
            ->fileManager
            ->downloadFile($image)
            ->getContent();

        if (ElcodiMediaImageResizeTypes::NO_RESIZE === $type) {
            $image->setContent($imageData);

            return $image;
        }

        $resizedImageData = $this
            ->resizeAdapter
            ->resize($imageData, $height, $width, $type);

        /**
         * We need to physically store the new resized
         * image in order to access its metadata, such as
         * file size, image dimensions, mime type etc.
         * Ideally, we should be doing this in memory.
         */
        $resizedFile = new File(tempnam(sys_get_temp_dir(), '_generated'));
        file_put_contents($resizedFile, $resizedImageData);

        $image = $this->createImage($resizedFile);
        $image->setContent($resizedImageData);

        unlink($resizedFile);

        return $image;
    }
405831
private function getImageTypeConstant($type)
    {
        switch ($type) {
            case 'jpg':
            case 'jpeg':
                return IMAGETYPE_JPEG;
            case 'gif':
                return IMAGETYPE_GIF;
            case 'png':
                return IMAGETYPE_PNG;
            case 'webp':
                return IMAGETYPE_WBMP;
            case 'webp':
                return IMAGETYPE_WBMP;
            case 'ico':
                return IMAGETYPE_ICO;
            case 'bmp':
                return IMAGETYPE_BMP;
            default:
                return IMAGETYPE_JPC;
        }
    }
354568
public function dispatchAssets($type)
    {
        switch ($type) {
            case 'css':
            case 'js':
                $headers = [
                    'Content-Type' => $type === 'css' ? 'text/css; charset=utf-8' : 'text/javascript; charset=utf-8',
                    'Cache-Control' => 'max-age=86400',
                ];
                $content = $this->renderBuffer(function () {
                    return $this->bar->dispatchAssets();
                });
                break;
            default:
                $headers = [
                    'Content-Type' => 'text/javascript; charset=utf-8',
                ];
                $content = $this->dispatch();
                break;
        }

        return [
            array_merge($headers, [
                'Content-Length' => strlen($content),
            ]),
            $content,
        ];
    }
1161640
function convert($type)
    {
        if (in_array($type, array('gif','png','jpg'))){
            $this->_transforms_str.='convert('.$type.')';
            $this->_convert = $type;
        }
        return $this;
    }
236271
public function extension(String $type = 'jpeg', Bool $dot = true) : String
    {
        return image_type_to_extension(Helper::toConstant($type, 'IMAGETYPE_'), $dot);
    }
693410
public function inline($type = 'jpg', $quality = 80)
    {
        $mime = $type;
        if ($mime == 'jpg') {
            $mime = 'jpeg';
        }

        return 'data:image/'.$mime.';base64,'.base64_encode(file_get_contents($this->cacheFile($type, $quality, true)));
    }
335513
private function getRandomImage($type, $placeholder)
    {
        $pathKey = $type === 'image' ? 'file' : 'filename';

        if ($placeholder && ($filename = $this->fetchPlaceholder($placeholder))) {
            return [$pathKey => $filename, 'title' => 'placeholder', 'alt' => 'placeholder'];
        }

        $images = $this->getImageFiles();
        if (empty($images)) {
            return null;
        }
        $imageName = array_rand($images);
        $image = $images[$imageName];
        $title = $image->getFilename($image->getExtension());
        $title = ucwords(str_replace('-', ' ', $title));

        return [$pathKey => $image->getPath(), 'title' => $title, 'alt' => $title];
    }
137918
public function getImagesOfType($type)
    {
        // Check to see if type is here.
        if (! in_array($type, $this->getImageTypes())) {
            throw new \Exception('Type not found in model '.self::class);
        }

        return $this->images()->where('image_type', '=', $type)->get();
    }
704663
protected function getUpLoadContentType($type)
    {
        switch ($type) {
            case self::UPLOAD_TYPE_IMAGE:
                return 'image/jpg';
                break;
            case self::UPLOAD_TYPE_VIDEO:
                return 'video/mp4';
                break;
            case self::UPLOAD_TYPE_VOICE:
                return 'audio/amr';
                break;
            case self::UPLOAD_TYPE_THUMB:
                return 'image/jpg';
                break;
            //@codeCoverageIgnoreStart
            default:
                break;
        }

        throw new Exception("unknown upload file type({$type})");
        //@codeCoverageIgnoreEnd
    }
408946
public function response( $quality = null, $type = null ) 
	{
		$response = CCResponse::create( $this->stringify( $quality, $type ) );

		if ( !is_null( $this->type ) )
		{
			$response->header( 'Content-Type', 'image/'.$this->type );
		}

		return $response;
	}