Sets the gravity if something should be cropped. (See {@see \Beluga\Drawing\Gravity}}::* constants)

@param  int $gravity
@return ImageSizeReducer
@throws \Beluga\ArgumentError
428205
public function setGravity( int $gravity ) : ImageSizeReducer
   {

      if ( ! \in_array( $gravity, Gravity::KNOWN_VALUES ) )
      {
         throw new ArgumentError( 'gravity', $gravity, 'Drawing.Image', 'Can not crop an image with an unknown gravity!' );
      }

      $this->data[ 'gravity' ] = $gravity;

      return $this;

   }
647796
public function setHeight($height)
    {
        $height = $this->convertUnit($height);
        $this->setAttributeDirectly('height', $height);

        return $this;
    }
745903
public function setConfig($config)
    {
        if (is_string($config)) {
            // Treat the parameter as a filepath
            $this->config = $this->createConfig($config);
        } elseif (is_array($config)) {
            $this->config = $this->createConfig($config);
        } elseif ($config instanceof ConfigInterface) {
            $this->config = $config;
        } else {
            throw new InvalidArgumentException(sprintf(
                'Configset must be an associative array, a file path, or an instance of %s',
                ConfigInterface::class
            ));
        }

        return $this;
    }
570761
public function setConstraints($constraints)
    {
        foreach ($constraints as $fieldName => $v) {
            if (is_array($v)) {
                foreach ($v as $constraintFromArray) {
                    $this->setConstraint($fieldName, $constraintFromArray);
                }
            } else {
                $this->setConstraint($fieldName, $v);
            }
        }

        return $this;
    }
774635
public function setAction($action)
    {
        $allowedValues = $this->getActionAllowableValues();
        if (!in_array($action, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'action', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['action'] = $action;

        return $this;
    }
394423
public function setDirection($direction)
    {
        if ($direction !== self::DIRECTION_FORWARD && $direction !== self::DIRECTION_REVERSE && $direction !== self::DIRECTION_BOTH) {
            throw new InvalidArgumentException('Invalid direction given');
        }
        $this->direction = $direction;

        return $this;
    }
938668
public function setScale($scale)
    {
        $valid = ['b', 'c', 'f', 'r'];
        $scale = substr((string) $scale, 0, 1);
        $scale = in_array($scale, $valid)
            ? $scale
            : (!empty($this->thumbConf['cropping']) ? substr($this->thumbConf['cropping'], 0, 1) : 'c');

        $this->scale = $scale;

        return $this;
    }
182184
private function setLogger($logger)
    {
        $psr = 'Psr\\Log\\LoggerInterface';
        if (!is_a($logger, $psr)) {
            throw new InvalidArgumentException(
                sprintf('Expected an instance of %s', $psr)
            );
        }

        $this->logger = $logger;
    }
377870
protected function setPort($port)
    {
        $this->uriString = null;

        if (null === $port) {
            $this->port = null;

            return $this;
        }

        if (! $this->isPortValid($port)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid port "%s" provided.',
                (is_object($port) ? get_class($port) : gettype($port))
            ));
        }
        $this->port = (int) $port;

        return $this;
    }
666649
public function transparent(String $rgb) : GD
    {
        imagecolortransparent($this->canvas, $this->allocate($rgb));

        return $this;
    }
716038
public function setGeometry(Geometry $geometry = null, bool $stopPropagation = false) {
        $this->geometry = $geometry;
        if($stopPropagation) {
            $this->stopPropagation();
        }
    }
469315
public function setConfig($config)
    {
        if (!is_array($config) && !$config instanceof ArrayAccess) {
            throw new InvalidArgumentException('Config has to be array or ArrayAccess');
        }
        $this->config = $config;

        return $this;
    }
183987
protected function filterCropScale($gravity)
    {
        $this
            ->resize($this->targetSize['width'], $this->targetSize['height'], static::FL_FILL_AREA)
            ->gravity($gravity)
            ->extent($this->targetSize['width'], $this->targetSize['height']);
    }
986232
public void setForegroundGravity(int foregroundGravity) {
        if (mForegroundGravity != foregroundGravity) {
            if ((foregroundGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) {
                foregroundGravity |= Gravity.START;
            }

            if ((foregroundGravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) {
                foregroundGravity |= Gravity.TOP;
            }

            mForegroundGravity = foregroundGravity;


            if (mForegroundGravity == Gravity.FILL && mForeground != null) {
                Rect padding = new Rect();
                mForeground.getPadding(padding);
            }

            requestLayout();
        }
    }
76993
public function setMax($max) : self
    {
        if (null === $max || (!is_float($max) && !is_int($max))) {
            throw new \InvalidArgumentException('max must be either a float or an integer.');
        }

        $this->max = $max;

        return $this;
    }
594753
public function setExtension($sExtension = null)
    {
        if (null === $sExtension) {
            return $this;
        }

        if (!in_array($sExtension, $this->aValidExtensions)) {
            $message = sprintf(
                'The extension "%s" is not a valid one, extension image for Gravatar can be: %s',
                $sExtension,
                implode(', ', $this->aValidExtensions)
            );

            throw new InvalidImageExtensionException($message);
        }

        $this->sExtension = $sExtension;

        return $this;
    }
54833
public static function fromString(string $data): self
    {
        if (false === $image = imagecreatefromstring($data)) {
            throw new InvalidArgumentException('Could not read image');
        }

        return new static($image);
    }