Set the quality of the resampled image

@param int $quality Quality level from 0 - 100
@return AssetContainer
@throws InvalidArgumentException
420920
public function Quality($quality)
    {
        $quality = $this->castDimension($quality, 'Quality');
        $variant = $this->variantName(__FUNCTION__, $quality);
        return $this->manipulateImage($variant, function (Image_Backend $backend) use ($quality) {
            return $backend->setQuality($quality);
        });
    }
760323
public function jpegoptim($quality = null)
    {
        return $quality === null ? $this->addItem('q', 'jpegoptim') : $this->addItem('q', 'jpegoptim', $quality);
    }
661552
private static function setQuality(int $quality = 90): void
    {
        $quality = $quality < 10 || $quality > 100 ? 90 : $quality;
        static::$quality = $quality;
        static::$qualityPNG = (int)\round((100 - $quality) / 10, 0);
    }
485563
public function copy($source, Array $settings = []) : GD
    {
        if( is_file($file = $source) )
        {
            $source = $this->createFrom($source);
        }

        if( ! is_resource($source) )
        {
            throw new InvalidArgumentException(NULL, '[resource]');
        }

        $this->alignImageWatermark($file);

        $xt     = $settings['xt']     ?? $this->target[0] ?? 0;
        $yt     = $settings['yt']     ?? $this->target[1] ?? 0;
        $xs     = $settings['xs']     ?? $this->source[0] ?? 0;
        $ys     = $settings['ys']     ?? $this->source[1] ?? 0;
        $width  = $settings['width']  ?? $this->width     ?? 0;
        $height = $settings['height'] ?? $this->height    ?? 0;

        imagecopy($this->canvas, $source, $xt, $yt, $xs, $ys, $width, $height);
        
        $this->defaultRevolvingVariables();

        return $this;
    }
357616
public function setJpegQuality($quality)
  {
    if (!is_numeric($quality) ||
      $quality < 0 ||
      $quality > 100) {
      throw new \Exception('Qualité JPEG : valeur numérique attendue de 0 à 100');
    }
    $this->jpgQuality = $quality;
  }
542913
public function resizeTo(
        int $width,
        int $height,
        bool $maintain_aspect = true,
        array $canvas_color = array('r' => 255, 'g' => 255, 'b' => 255)
    ) : ImageResize
    {
        if ($this->resizer !== null) {
            try {
                $this->resizer->setOptions($width, $height, $this->quality, $maintain_aspect, $canvas_color);
            } catch (\Exception $e) {
                echo $e->getMessage();
            }
        }

        return $this;
    }
283066
public function save($file = null, $quality = 90) {

		if(null !== $file && false === is_string($file)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($file)), E_USER_ERROR);
		}

		if(null !== $file && false === is_writable(dirname($file))) {
			return trigger_error(sprintf('File in "%s" directory is not writable', dirname($file)), E_USER_ERROR);
		}

		if(false === ('-' . intval($quality) == '-' . $quality)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($quality)), E_USER_ERROR);
		}

		if($quality < 0 || $quality > 100) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be between 0 and 100, "%s" given', __METHOD__, $quality), E_USER_ERROR);
		}

		foreach($this -> commands as $command) {
			$resource = call_user_func_array([$this -> call(), $command -> method], $command -> params);
		}

		switch(strtolower($this -> extension)) {

			case 'bmp'	: imagewbmp($resource, $file); break;
			case 'png'	: imagepng($resource, $file, $this -> getQuality($quality, $this -> extension)); break;
			case 'gif'	: imagegif($resource, $file); break;
			default 	: imagejpeg($resource, $file, $this -> getQuality($quality, $this -> extension)); break;
		}
	}
941821
public function resize($width, $height, $x = 0, $y = 0)
    {
        if ( !$this->newImage )
        {
            $this->create($width, $height);
        }

        if ( !is_numeric($width) ) {
            throw new \InvalidArgumentException('$width must be numeric');
        }

        if ( !is_numeric($height) ) {
            throw new \InvalidArgumentException('$height must be numeric');
        }

        $type = $this->source['type'];

        imagecopyresampled(
            $this->newImage,
            $this->sourceImage,
            0, 0,
            $x, $y,
            $width, $height,
            $this->source['width'], $this->source['height']);

        return $this;
    }
672409
public function outputBase64($quality = null)
    {
        ob_start();
        $this->save(-1, $quality);
        $image_data = ob_get_contents();
        ob_end_clean();

        return 'data:' . $this->original_info['mime'] . ';base64,' . base64_encode($image_data);
    }
540314
public function setFileSize($size)
    {
        if ($size === null) {
            $this->fileSize = null;

            return $this;
        }

        if (!is_numeric($size)) {
            throw new InvalidArgumentException('File size must be an integer or a float.');
        }

        $this->fileSize = $size;

        return $this;
    }
203573
public function desaturate($amount)
    {
        if ($amount < 0 || $amount > 100) {
            throw new InvalidArgumentException('The given amount must be between 0 and 100');
        }
        $amount /= 100;
        $this->saturation -= $this->saturation * $amount;

        return $this;
    }
831387
public function setColor($color)
	{
		if ( ! $this->isValidColor($color))
		{
			throw new \InvalidArgumentException('Invalid color format.');
		}
		
		$this->color = (string) $color;
		
		return $this;
	}
270098
public function saveImage($saveImageFilePath, $quality = null)
    {
        $quality = empty($quality) ? $this->config->offsetGet('quality') : $quality;
        $optimizerConfig = $this->config->offsetGet('optimizer');

        if ($this->driver->save($saveImageFilePath, $quality)) {
            if ($optimizerConfig === 'default') {
                $optimizer = new Optimizer();
                $optimizer->optimize($saveImageFilePath);
            } elseif ( ! empty($optimizerConfig[ 'factory' ])) {
                $factory = $optimizerConfig[ 'factory' ];
                $optimizer = new Optimizer();

                switch ($factory) {
                    case 'imageoptim';
                        $factory = new Imageoptim();
                        $factory->setUsername($optimizerConfig[ 'username' ]);
                        $optimizer->setImageFactory($factory);
                        break;
                }

                $optimizer->optimize($saveImageFilePath);
            }

            return true;
        }

        return false;
    }
1008894
public function setRating($rating)
    {
        $this->cachedParams = null;

        $rating = strtolower($rating);

        if ( ! in_array($rating, $this->supportedRatings))
            throw Exceptions\InvalidImageRatingException::make($rating);

        $this->rating = $rating;

        return $this;
    }
745
public function build($dir, $quality, array $options = array())
    {
        // Alter default quality on demand
        if (isset($options['quality'])) {
            $quality = $options['quality'];
        }

        return new Thumb($dir, $options['dimensions'], $quality);
    }
1368476
public function encode($format = null, $quality = 90)
    {
        return $this->driver->encode($this, $format, $quality);
    }
595646
public function setOutputFormat($format = null, $quality = null, $filters = null) {

		if ($format) {
			$format = strtolower($format);

			if (in_array($format, static::$_allowed_formates)) {
				$this->_output_format = $format;

				# fix file extension if this method was called after calling setSaveOptions Method
				if ($this->_save_path) {
					$this->_save_name = preg_replace(
						'/(?<=\.)(?:png|jpeg|jpg|gif)$/i',
						$this->_output_format,
						$this->_save_name
					);

					$this->_save_path = $this->_save_dir . DIRECTORY_SEPARATOR . $this->_save_name;
				}
			}
		}

		// Quality
		$this->_output_options = [];
		if (is_numeric($quality)) {
			// if($format == 'jpg' || $format == 'jpeg')
			// {
			// 	if($quality < 0 || $quality > 100)
			// 		throw new ImageException(__METHOD__ . ' ' . $format . ' quality must be between 0-100');
			// }
			// else if($format == 'png')
			// {
			// 	if($quality < 0 || $quality > 9)
			// 		throw new ImageException(__METHOD__ . ' ' . $format . ' quality must be between 0-9');
			// }

			if ($this->_output_format == 'jpg' || $this->_output_format == 'jpeg') {
				$quality = round($quality * 100 / 100);
			} else if ($this->_output_format == 'png') {
				$quality = round($quality * 9 / 100);
			}

			$this->_output_options[] = $quality;
		}

		// Filters
		if ($filters !== null) {
			// Filters must come after quality
			if (empty($this->_output_options)) {
				$this->_output_options[] = null;
			}

			$this->_output_options[] = $filters;
		}

		return $this;
	}