Generates a reduced quality version of the current image
@config
@return void
511954
public function MicroImage()
    {
        $pixel = $this->config()->pixelate;
        $blur = $this->config()->blur;
        $quality = $this->config()->quality;
        $scale = $this->config()->scale;
        
        $variant = $this->owner->variantName(__FUNCTION__, $pixel, $blur, $quality, $scale);
        return $this->owner->manipulateImage(
            $variant, 
            function (Image_Backend $backend) use ($pixel, $blur, $quality, $scale) {
                $clone = clone $backend;
                $resource = clone $backend->getImageResource();
                $resource->pixelate($pixel)->blur($blur)->encode('jpg', $quality);
                if ($scale != 100) {
                    $width = $backend->getWidth() * ($scale/100);
                    $height = $backend->getHeight() * ($scale/100);
                    $resource->resize($width, $height);
                }
                $clone->setImageResource($resource);
                return $clone;
            }
        );
    }
1098112
public static function generate_no_image()
    {
        // See if the image is already in the DB
        $no_image = "no-image.png";
        $image = File::find($no_image);

        // If not, create new record
        if (!isset($image)) {
            $reflector = new ReflectionClass(self::class);
            $curr_file = dirname($reflector->getFileName());
            $curr_file = str_replace(
                "src/helpers",
                "client/dist/images/no-image.png",
                $curr_file
            );

            $config = array(
                'conflict' => AssetStore::CONFLICT_OVERWRITE,
                'visibility' => AssetStore::VISIBILITY_PUBLIC
            );
            
            $image = Injector::inst()->create(Image::class);
            $image->setFromLocalFile(
                $curr_file,
                $no_image,
                null,
                null,
                $config
            );
            $image->write();
            $image->publishSingle();
        }

        return $image;
    }
477524
private function fixPngToJpegDefaultBackgroundColor()
    {
        $black = imagecreatetruecolor($this->width, $this->height);

        if (imagecopyresampled(
            $black,
            $this->getResource(),
            0,
            0,
            0,
            0,
            $this->getWidth(),
            $this->getHeight(),
            $this->getWidth(),
            $this->getHeight()
        )) {
            $this->resource = $black;
        }
    }
1043146
public function cmdDeleteImageStyle()
    {
        $id = $this->getParam(0);

        if (empty($id) || !is_numeric($id)) {
            $this->errorAndExit($this->text('Invalid argument'));
        }

        if (!$this->image_style->delete($id)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        $this->output();
    }
1175538
protected function scale()
    {
        $config = config('image', true);

        if ( ! empty($this->imageQuality)) {
            $config->offsetSet('quality', intval($this->imageQuality));
        }

        if ($config->cached === true) {
            if ($this->imageFilePath !== $this->imageNotFoundFilename) {
                $cacheImageKey = 'image-' . $this->imageScale . '-' . str_replace($this->storagePath, '',
                        $this->imageFilePath);

                if (cache()->hasItemPool('images')) {
                    $cacheItemPool = cache()->getItemPool('images');

                    if ($cacheItemPool->hasItem($cacheImageKey)) {
                        $cacheImageString = $cacheItemPool->getItem($cacheImageKey)->get();

                        $manipulation = new Manipulation($config);
                        $manipulation->setImageFile($this->imageFilePath);
                        $manipulation->setImageString($cacheImageString);
                        $manipulation->displayImage(intval($this->imageQuality), $this->imageFileMime);
                    } else {
                        $manipulation = new Manipulation($config);
                        $manipulation->setImageFile($this->imageFilePath);
                        $manipulation->scaleImage($this->imageScale);
                        $cacheItemPool->save(new Item($cacheImageKey, $manipulation->getBlobImage(), false));

                        $manipulation->displayImage(intval($this->imageQuality), $this->imageFileMime);
                        exit(EXIT_SUCCESS);
                    }
                }
            }
        }

        $manipulation = new Manipulation($config);
        $manipulation->setImageFile($this->imageFilePath);
        $manipulation->scaleImage($this->imageScale);
        $manipulation->displayImage(intval($this->imageQuality), $this->imageFileMime);
        exit(EXIT_SUCCESS);
    }
1245687
public function resizeImage($path_imagen,$path_imagen_new,$image_info=array(),$image_config=array())
    {
        $imagen_ext = $this->getExtension($path_imagen);
        if ($image_config[2]===true && $image_config[3]===true) {
            Imagen::open($path_imagen)->zoomCrop($image_info['width'],$image_info['height'])->save($path_imagen_new,$imagen_ext,$this->config['images']['quality']);
            return true;
        }elseif ( $image_config[2]===true && $image_config[3]===null ) {
            Imagen::open($path_imagen)->scaleResize($image_info['width'],null)->save($path_imagen_new,$imagen_ext,$this->config['images']['quality']);
            return true;
        }elseif ( $image_config[2]===null && $image_config[3]===true ) {
            Imagen::open($path_imagen)->scaleResize(null,$image_info['height'])->save($path_imagen_new,$imagen_ext,$this->config['images']['quality']);
            return true;
        }else{
            return false;
        }
    }
386046
public function greyscale() {

		$todo = new \stdClass();

		$todo->method		= __FUNCTION__;
		$todo->parameters	= array();

		$this->queue[] = $todo;

	}
1103545
public function reset()
    {
        parent::reset();

        if ($this->image) {
            $this->image();
            $this->medium_querystring = [];
            $this->filter();
            $this->clearAlternatives();
        }

        $this->format = 'guess';
        $this->quality = $this->default_quality;

        $this->debug_watermarked = false;

        return $this;
    }
1321849
protected function buildImageResize() {
    $image = Image::make($this->upload_path . $this->file_name)->orientate();

    $image->resize($this->preset->width, $this->preset->height , function ($constraint) {
      $constraint->aspectRatio();
      $constraint->upsize();
    });

    //if background_color is not set, do not resizeCanvas with black color, to avoid black zones in images. 
    if(isset($this->preset->background_color))
    {
      $image->resizeCanvas($this->preset->width, $this->preset->height, 'center', FALSE, $this->preset->background_color);
    }
    
    return $image;
  }
829055
private function prepareConfigs()
    {
        $this->library = Config::get('imageupload.library', 'gd');
        $this->quality = Config::get('imageupload.quality', 90);
        $this->uploadpath = Config::get('imageupload.path', public_path('uploads/images'));
        $this->newfilename = Config::get('imageupload.newfilename', 'original');
        $this->dimensions = Config::get('imageupload.dimensions');
        $this->suffix = Config::get('imageupload.suffix', true);
        $this->exif = Config::get('imageupload.exif', false);
        $this->output = Config::get('imageupload.output', 'array');

        $this->intervention->configure(['driver' => $this->library]);

        return $this;
    }
691515
public function minify()
	{
		$data = '';

		foreach ($this->files as $fileData)
		{
			$fileData = $this->handleFile($fileData);

			$data .= $this->doMinify($fileData['content'], $fileData['options']);
		}

		return $data;
	}
1261694
public function getDefaultJpegQuality()
    {
        $result = $this->config->get('concrete.misc.default_jpeg_image_compression');
        if ($this->valn->integer($result, 0, 100)) {
            $result = (int) $result;
        } else {
            $result = static::DEFAULT_JPEG_QUALITY;
        }

        return $result;
    }
66134
protected function generate_cached_image() {
    $cached_image = $this->get_cached_image_path();

    if (file_exists($cached_image)) {
      return TRUE;
    }

    $path_info = pathinfo($cached_image);

    if (!is_dir($path_info['dirname'])) {
      mkdir($path_info['dirname'], 0777, TRUE);
    }

    if (!($image = $this->buildImage())) {
      return FALSE;
    }

    if ($image->save($cached_image, $this->quality)) {
      return TRUE;
    }

    return FALSE;
  }
651109
protected function imageAllocate()
    {
        // Cleanup
        if (!empty($this->im)) {
            imagedestroy($this->im);
        }

        $this->im = imagecreatetruecolor($this->width*$this->scale, $this->height*$this->scale);

        // Background color
        $this->GdBgColor = imagecolorallocate(
            $this->im,
            $this->backgroundColor[0],
            $this->backgroundColor[1],
            $this->backgroundColor[2]
        );
        imagefilledrectangle($this->im, 0, 0, $this->width*$this->scale, $this->height*$this->scale, $this->GdBgColor);

        // Foreground color
        $color           = $this->colors[mt_rand(0, sizeof($this->colors)-1)];
        $this->GdFgColor = imagecolorallocate($this->im, $color[0], $color[1], $color[2]);

        // Shadow color
        if (!empty($this->shadowColor) && is_array($this->shadowColor) && sizeof($this->shadowColor) >= 3) {
            $this->GdShadowColor = imagecolorallocate(
                $this->im,
                $this->shadowColor[0],
                $this->shadowColor[1],
                $this->shadowColor[2]
            );
        }
    }
355769
public function createCopy(): AbstractResize
    {
        $this->createCanvas();

        $this->intermediate['copy'] = imagecreatefrompng($this->source['path'] . $this->source['file']);
        if ($this->intermediate['copy'] === false) {
            throw new \Exception('Call to imagecreatefrompng failed');
        }

        $this->resampleCopy();

        return $this;
    }
940265
protected function image_element_original() {
    $path = $this->get_original_image_path();
    $class = $this->get_class();

    $data['src'] = $this->generateUrl($path);
    $data['img'] = '<img src="'. $data['src'] .'"'. $class .' alt="'. $this->alt .'" title="'. $this->title .'"/>';
    $data['img_nosize'] = '<img src="'. $data['src'] .'"'. $class .' alt="'. $this->alt .'" title="'. $this->title .'"/>';

    return (object) $data;
  }
1190726
protected function configuration()
    {
        $this->options = array_merge(['accept' => 'image/*'], $this->options);
        $croppedDataInput = $this->croppedDataAttribute;
        if ($this->hasModel()) {
            $croppedDataInput = Html::getInputName($this->model, $croppedDataInput);
        } else {
            $croppedDataInput = $this->croppedDataName;
        }
        $this->pluginOptions = array_merge([
            'selectors' => [
                'fileInput' => sprintf('#%s input[type="file"]', $this->id),
                'btnCrop' => sprintf('#%s .btn-crop', $this->id),
                'btnReset' => sprintf('#%s .btn-reset', $this->id),
                'btnScaleIn' => sprintf('#%s .btn-scale-in', $this->id),
                'btnScaleOut' => sprintf('#%s .btn-scale-out', $this->id),
                'croppedContainer' => sprintf('#%s .cropped-images-cropbox', $this->id),
                'croppedDataInput' => sprintf('#%s input[name="%s"]', $this->id, $croppedDataInput),
                'messageContainer' => sprintf('#%s .message-container-cropbox', $this->id),
            ],
        ], $this->pluginOptions);
    }