public function renderImage($data = [])
    {
        ini_set('memory_limit', '512M');
        $cacheFile = Yii::getAlias('@cachePath/' . $this->filename);
        $baseSource = $this->baseSource;

        if (!isset($data['width']) && !isset($data['height'])) {
            if (!file_exists(Yii::getAlias('@root') . Yii::getAlias('@cacheDir/' . $this->filename))) {
                //only cache if not available
                try {
                    $image = Image::getImagine();
                    $newImage = $image->open($baseSource);
                    $newImage->save($cacheFile);
                } catch (\Exception $e) {
                    //seems like image is corrupt!
                }
            }

            return Yii::getAlias('@cacheDir/' . $this->filename);
        } else {
            $path_parts = pathinfo($cacheFile);
            $newFileName = $path_parts['filename'] . '-' . $data['width'] . '-' . $data['height'] . '.' . $path_parts['extension'];
            //http://imagine.readthedocs.org/en/latest/
            if (!file_exists(Yii::getAlias('@root') . Yii::getAlias('@cacheDir/' . $newFileName))) {
                //only cache if not available
                try {
                    Image::thumbnail($baseSource, $data['width'], $data['height'])
                        ->save(Yii::getAlias('@cachePath/' . $newFileName));
                } catch (\Exception $e) {
                    //seems like image is corrupt!
                }
            }

            if (isset($data['imgTag'])) {
                return Html::img(Yii::getAlias('@cacheDir/' . $newFileName));
            } else {
                return Yii::getAlias('@cacheDir/' . $newFileName);
            }
        }
    }