Set options to use when processing image.

@param array $args used when processing image.

@return $this
189681
public function setOptions($args)
    {
        $this->log("Set new options for processing image.");

        $defaults = array(
            // Options for calculate dimensions
            'newWidth'    => null,
            'newHeight'   => null,
            'aspectRatio' => null,
            'keepRatio'   => true,
            'cropToFit'   => false,
            'fillToFit'   => null,
            'crop'        => null, //array('width'=>null, 'height'=>null, 'start_x'=>0, 'start_y'=>0),
            'area'        => null, //'0,0,0,0',
            'upscale'     => self::UPSCALE_DEFAULT,

            // Options for caching or using original
            'useCache'    => true,
            'useOriginal' => true,

            // Pre-processing, before resizing is done
            'scale'        => null,
            'rotateBefore' => null,
            'autoRotate'  => false,

            // General options
            'bgColor'     => null,

            // Post-processing, after resizing is done
            'palette'     => null,
            'filters'     => null,
            'sharpen'     => null,
            'emboss'      => null,
            'blur'        => null,
            'convolve'       => null,
            'rotateAfter' => null,

            // Output format
            'outputFormat' => null,
            'dpr'          => 1,

            // Postprocessing using external tools
            'lossy' => null,
        );

        // Convert crop settings from string to array
        if (isset($args['crop']) && !is_array($args['crop'])) {
            $pices = explode(',', $args['crop']);
            $args['crop'] = array(
                'width'   => $pices[0],
                'height'  => $pices[1],
                'start_x' => $pices[2],
                'start_y' => $pices[3],
            );
        }

        // Convert area settings from string to array
        if (isset($args['area']) && !is_array($args['area'])) {
                $pices = explode(',', $args['area']);
                $args['area'] = array(
                    'top'    => $pices[0],
                    'right'  => $pices[1],
                    'bottom' => $pices[2],
                    'left'   => $pices[3],
                );
        }

        // Convert filter settings from array of string to array of array
        if (isset($args['filters']) && is_array($args['filters'])) {
            foreach ($args['filters'] as $key => $filterStr) {
                $parts = explode(',', $filterStr);
                $filter = $this->mapFilter($parts[0]);
                $filter['str'] = $filterStr;
                for ($i=1; $i<=$filter['argc']; $i++) {
                    if (isset($parts[$i])) {
                        $filter["arg{$i}"] = $parts[$i];
                    } else {
                        throw new Exception(
                            'Missing arg to filter, review how many arguments are needed at
                            http://php.net/manual/en/function.imagefilter.php'
                        );
                    }
                }
                $args['filters'][$key] = $filter;
            }
        }

        // Merge default arguments with incoming and set properties.
        //$args = array_merge_recursive($defaults, $args);
        $args = array_merge($defaults, $args);
        foreach ($defaults as $key => $val) {
            $this->{$key} = $args[$key];
        }

        if ($this->bgColor) {
            $this->setDefaultBackgroundColor($this->bgColor);
        }

        // Save original values to enable re-calculating
        $this->newWidthOrig  = $this->newWidth;
        $this->newHeightOrig = $this->newHeight;
        $this->cropOrig      = $this->crop;

        return $this;
    }
1016718
public function setArgs(array $args)
    {
        foreach ($args as $k => $v) {
            if (is_numeric($k)) {
                $this->args[$k] = $v;
            } else {
                $this->kwargs[$k] = $v;
            }
            ksort($this->args);
        }
        return $this;
    }
508769
public function setArguments($arguments)
    {
        foreach ($arguments as $name => $argument) {
            $this->setArgument($name, $argument);
        }

        return $this;
    }
511874
public function setOptions(array $options)
    {
        if (isset($options['indent'])) {
            $this->indent = $options['indent'];
        }
        if (isset($options['quote'])) {
            $this->quote = $options['quote'];
        }
        if (isset($options['foregroundColors'])) {
            $this->foregroundColors = $options['foregroundColors'];
        }
        if (isset($options['backgroundColors'])) {
            $this->backgroundColors = $options['backgroundColors'];
        }
        return $this;
    }
1191091
public function setMenu($arg) {
        if (is_array($arg)) {
            $this->menu = $arg;
        } else {
            $this->menu[] = $arg;
        }
        return $this;
    }
332338
protected function setParams(array $args)
    {
        if (!empty($args)) {
            $request = '?';
        } else {
            $request = '';
        }

        foreach ($args as $key => $value) {
            if (is_numeric($key)) {
                if ($request != '?') {
                    $request .= '&';
                }
                $request .= $value;
            } elseif (is_string($key)) {
                if ($request != '?') {
                    $request .= '&';
                }
                $request .= $key.'='.$value;
            }
        }

        return $request;
    }
1344716
public function setMediaId($arg) {
        if (empty($this->type)) {
            $this->setType(self::MEDIA);
        }
        $this->mediaId = $arg;
        return $this;
    }
809622
public function withArgs($args = [])
    {
        if (!is_array($args)) {
            $args = func_get_args();
        }

        $this->args = $args;
        return $this;
    }
925188
public function setOptions(array $options)
    {
        foreach ($options as $opt => $val) {
            $this->setOption($opt, $val);
        }

        return $this;
    }
1006140
private function processOptions(RawArgs $args, Command $currentCommand, array $optionsToTest)
    {
        foreach ($optionsToTest as $option) {
            $commands = $currentCommand->getNamedSubCommands();

            if (!$commands->contains($option)) {
                continue;
            }

            $nextCommand = $commands->get($option);

            if (!$nextCommand->getConfig() instanceof OptionCommandConfig) {
                break;
            }

            $currentCommand = $nextCommand;
        }

        return $this->processDefaultSubCommands($args, $currentCommand);
    }
482336
public function setOptions(array $options)
    {
        foreach ($options as $option => $value) {
            if (property_exists($this, $option)) {
                $this->{$option} = $value;
            }
        }

        return $this;
    }
490784
public function setOptions(array $options)
    {
        $this->validateOptions($options, $this->type);

        $this->options = $options;

        return $this;
    }
921797
public function merge(...$args): self
    {
        $args = array_map([Arr::class, 'toArray'], $args);

        return new static(array_merge($this->storage, ...$args));
    }
220014
public function format($args)
    {
        if ($this->isArray($args)) {
            $value = vsprintf($this->val(), $args);
        } else {
            if ($this->isInstanceOf($args, new ArrayObject([]))) {
                $value = vsprintf($this->val(), $args->val());
            } else {
                $value = sprintf($this->val(), $args);
            }
        }
        $this->val($value);

        return $this;
    }
831320
protected function initValues(array $args)
    {
        $uses = class_uses(get_class($this));
        foreach ($uses as $use) {
            $resetMethod = 'init' . basename(strtr($use, '\\', '/'));
            if (method_exists($this, $resetMethod)) {
                $this->$resetMethod($args);
            }
        }
        return $this;
    }
747453
public function setFiles($data, ...$args)
    {
        if (is_array($data)) {
            return $this->set('files', $data);
        }

        if (count($args) === 0) {
            return $this;
        }

        return $this->set('files', $data, ...$args);
    }
1218782
public function removeArgument($arg)
    {
        if (($key = array_search($arg, $this->arguments)) !== false) {
            unset($this->arguments[$key]);
        }

        return $this;
    }