Create Transformations

@param                    $image
@param ImageConfiguration $config
@param ImageRecord        $image_record
@return array
974620
private function _createTransformations($image, ImageConfiguration $config, ImageRecord $image_record)
    {
        foreach ($config->sizes as $size) {
            /* create filename */
            $fn = $size->prefix .
                str_replace(".$image_record->extension", '', $image_record->filename) .
                "$size->suffix.$image_record->extension";

            /* initialize fluent image editor */
            $editor = new ImageEditor($image);

            /* create transformation */
            $transformed_image = $editor->resize($size->width, $size->height)->setQuality($size->quality)->getStream();

            /* store on disk */
            $size_on_disk = $this->storage->put($transformed_image, $config->primary_disk, "$image_record->path/$image_record->uuid", $fn);

            /* create record */
            $transformation_records[] = $this->image_transformation_repo->create([
                'name'     => $size->name,
                'filename' => $fn,
                'disk'     => $config->primary_disk,
                'width'    => $size->width ?? round($size->height / $image_record->height * $image_record->width),
                'height'   => $size->height ?? round($size->width / $image_record->width * $image_record->height),
                'quality'  => $size->quality,
                'size'     => $size_on_disk,
            ], $image_record);
        }

        return $transformation_records ?? [];
    }
1372299
private function transformRecords(RecordCollection $records, array $transformers, $context)
    {
        foreach ($transformers as $transformer) {
            if ($transformer instanceof PorterAware) {
                $transformer->setPorter($this);
            }

            $records = $transformer->transform($records, $context);
        }

        return $records;
    }
1114067
public static function resizeImg($image, $width, $height = 0)
    {
        $newImg = self::getImg($image, $width, $height, false, ManipulatorInterface::THUMBNAIL_OUTBOUND);

        if(self::copyImg($newImg, $image)){
            File::delFile($newImg);
        }
    }
464373
public function createWithParent( $parent, $config = [] ) {

		$modelClass	= static::$modelClass;

		$parentId	= $config[ 'parentId' ];
		$parentType	= $config[ 'parentType' ];
		$type		= isset( $config[ 'type' ] ) ? $config[ 'type' ] : $parent->type;
		$order		= isset( $config[ 'order' ] ) ? $config[ 'order' ] : 0;

		$file = null;

		switch( $parent->type ) {

			case 'image': {

				$file = $this->fileService->saveImage( $parent );
			}
			// TODO: Add case to save cross-browser compatible videos
			default: {

				$file = $this->fileService->saveFile( $parent );
			}
		}

		$model = new $modelClass;

		$model->modelId		= $file->id;
		$model->parentId	= $parentId;
		$model->parentType	= $parentType;

		$model->type	= $type;
		$model->order	= $order;
		$model->active	= true;

		return parent::create( $model );
	}
1304364
private function getPathsForVolumeAsset($image)
    {
        try {
            $this->transformPath = ImagerHelpers::getTransformPathForAsset($image);
        } catch (InvalidConfigException $e) {
            Craft::error($e->getMessage(), __METHOD__);
            throw new ImagerException($e->getMessage(), $e->getCode(), $e);
        }

        $runtimeImagerPath = Craft::$app->getPath()->getRuntimePath().'/imager/';

        $this->url = $image->getUrl();
        $this->path = FileHelper::normalizePath($runtimeImagerPath.$this->transformPath.'/');
        $this->filename = $image->getFilename();
        $this->basename = $image->getFilename(false);
        $this->extension = $image->getExtension();

        try {
            FileHelper::createDirectory($this->path);
        } catch (Exception $e) {
            Craft::error($e->getMessage(), __METHOD__);
            throw new ImagerException($e->getMessage(), $e->getCode(), $e);
        }
    }
628664
public function transformImage($file, $transform, $transformDefaults = null, $configOverrides = null)
    {
        $image = Plugin::$plugin->imager->transformImage($file, $transform, $transformDefaults, $configOverrides);

        return $image;
    }
132366
protected function transformRecord($record)
    {
        $columnNames = $this->columnManager->getRequestedColumnNames();
        $columnNames->transform(function ($item) use ($record) {
            return $this->getColumnValue($item, $record);
        });

        $datatableParameters = $this->getDatatableParameters($record);

        return array_merge($datatableParameters, $columnNames->toArray());
    }
70212
public function getImageConfig($imageType, $size, $property)
	{
		$config = $this->getConfigPrefix().'images.' . $imageType . '.';
		if ($size == 'original')
		{
			$config .= 'original.';
		}
		elseif (!is_null($size))
		{
			$config .= 'sizes.' . $size . '.';
		}
		$config .= $property;
		return \Config::get($config);
	}
1138106
public function imageProcessor(array $config = [], $renew = false) {
		if (!empty($this->_imageProcessor) && $renew === false) {
			return $this->_imageProcessor;
		}
		$this->loadImageProcessingFromConfig();
		$class = $this->_imageProcessorClass;
		$this->_imageProcessor = new $class($config);

		return $this->_imageProcessor;
	}
1259853
private function createImagineInstance()
    {
        try {
            if (ImagerService::$imageDriver === 'gd') {
                return new \Imagine\Gd\Imagine();
            }

            if (ImagerService::$imageDriver === 'imagick') {
                return new \Imagine\Imagick\Imagine();
            }
        } catch (RuntimeException $e) {
            // just ignore for now
        }

        return null;
    }
3114
public static function getImageInfo($image, array $config = null)
    {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        $img = new static($image['value'], $finfo, $config);

        $curl = $img->getConnection();
        curl_exec($curl);
        curl_close($curl);

        $info = $img->getInfo();

        finfo_close($finfo);

        return $info;
    }
437748
public function create( $model, $config = [] ) {

		$image 	= isset( $config[ 'image' ] ) ? $config[ 'image' ] : null;

		$slider	= Yii::$app->factory->get( 'fxSliderService' )->getById( $model->sliderId );

		$this->fileService->saveImage( $image, [ 'model' => $model, 'attribute' => 'imageId', 'width' => $slider->slideWidth, 'height' => $slider->slideHeight ] );

		return parent::create( $model, $config );
	}
1373359
public function run(Image $image)
    {
        $width = $this->getWidth();
        $height = $this->getHeight();
        $fit = $this->getFit();
        $dpr = $this->getDpr();

        list($width, $height) = $this->resolveMissingDimensions($image, $width, $height);
        list($width, $height) = $this->applyDpr($width, $height, $dpr);
        list($width, $height) = $this->limitImageSize($width, $height);

        if ((int) $width !== (int) $image->width() or (int) $height !== (int) $image->height()) {
            $image = $this->runResize($image, $fit, (int) $width, (int) $height);
        }

        return $image;
    }
713117
function buildImages(conf, undertaker) {

    const imageMinConfig = {
      progressive: true,
      svgoPlugins: [{
        removeViewBox: false
      }, {
        cleanupIDs: true
      }, {
        cleanupAttrs: true
      }]
    };

    const imageSrc = path.join(conf.themeConfig.root, conf.themeConfig.images.src, '**', '*');
    const imageDest = path.join(conf.themeConfig.root, conf.themeConfig.images.dest);

    return undertaker.src(imageSrc)
      .pipe(imagemin(imageMinConfig))
      .pipe(undertaker.dest(imageDest));

}
254760
protected function received(Image $image, Slice $config, $minimal = true): Slice
    {
        $width  = (int)$config->getRequired('width');
        $height = (int)$config->getRequired('height');

        $shiftWidth  = 0;
        $shiftHeight = 0;

        $_width  = $width;
        $_height = $height;

        if ($image->height() < $image->width())
        {
            $_height     = $image->height() * $width / $image->width();
            $shiftHeight = ($_height - $height) / 2;
        }
        else
        {
            $_width     = $image->width() * $height / $image->height();
            $shiftWidth = ($_width - $width) / 2;
        }

        if ($minimal ^ $_width > $width)
        {
            $_height = $_height * $width / $_width;
            $_width  = $width;
        }

        if ($minimal ^ $_height > $height)
        {
            $_width  = $_width * $height / $_height;
            $_height = $height;
        }

        return new Slice([
            'config'   => [
                'width'  => $width,
                'height' => $height,
            ],
            'received' => [
                'width'  => (int)$_width,
                'height' => (int)$_height,
            ],
            'shift'    => [
                'width'  => (int)$shiftWidth,
                'height' => (int)$shiftHeight,
            ]
        ]);
    }
1362145
public function imageSizeName($path,$imagen,$image_config)
    {
        $result = array("name"=>'',"width"=>0,"height"=>0);
        $imagen_ext = $this->getExtension($imagen);
        $imagen_name = $this->removeExtension($imagen);
        if ($image_config[2]===true && $image_config[3]===true) {
            $fullpath_new = $imagen_name.'-'.$image_config[0].'x'.$image_config[1].'.'.$imagen_ext;
            $result['name'] = $fullpath_new;
            $result['width'] = $image_config[0];
            $result['height'] = $image_config[1];
        }elseif ( $image_config[2]===true && $image_config[3]===null ) {
            $imagesize = getimagesize($this->getFullPath().$path.$imagen);
            $imagesize_new = $this->getImageCalSize(array($imagesize[0],$imagesize[1]),$image_config);
            $fullpath_new = $imagen_name.'-'.$imagesize_new[0].'x'.$imagesize_new[1].'.'.$imagen_ext;
            $result['name'] = $fullpath_new;
            $result['width'] = $imagesize_new[0];
            $result['height'] = $imagesize_new[1];
        }elseif ( $image_config[2]===null && $image_config[3]===true ) {
            $imagesize = getimagesize($this->getFullPath().$path.$imagen);
            $imagesize_new = $this->getImageCalSize(array($imagesize[0],$imagesize[1]),$image_config);
            $fullpath_new = $imagen_name.'-'.$imagesize_new[0].'x'.$imagesize_new[1].'.'.$imagen_ext;
            $result['name'] = $fullpath_new;
            $result['width'] = $imagesize_new[0];
            $result['height'] = $imagesize_new[1];
        }
        return $result;
    }
680468
public function create($image, $thumbnailWidth = 100, $thumbnailHeight = 100)
    {
        $this->setupTargetPath($image);
        $this->setupTargetImage($image);

        $this->transformation->thumbnail(new Image\Box($thumbnailWidth, $thumbnailHeight))
                             ->apply($this->imagine->open($image))
                             ->save($this->thumbnailImage);

        $this->imageSize = getimagesize($this->thumbnailImage);
    }