src/includes/classes/Core/Utils/Image.php
protected function compressSvg(string $file, array $args = []): bool
    {
        if (!$this->c::canCallFunc('exec')) {
            return false;
        }
        $default_args = [
            'precision'   => 0,
            'output_file' => '',
        ];
        $args += $default_args; // Defaults.

        if (!$file || !is_file($file)) {
            return false; // Not possible.
        }
        $args['precision'] = (int) ($args['precision'] ?: 4);
        $args['precision'] = max(1, min(8, $args['precision']));

        $args['output_file'] = (string) $args['output_file'];
        $args['output_file'] = $args['output_file'] ?: $file;

        $output_file_existed_prior = is_file($args['output_file']);

        $esc_file        = $this->c::escShellArg($file);
        $esc_precision   = $this->c::escShellArg($args['precision']);
        $esc_output_file = $this->c::escShellArg($args['output_file']);
        exec('svgo --quiet --precision='.$esc_precision.' --output='.$esc_output_file.' '.$esc_file, $_, $status);

        if ($status === 0) {
            return true; // Success.
        } else {
            if (!$output_file_existed_prior && is_file($args['output_file'])) {
                unlink($args['output_file']);
            }
            return false;
        }
    }
protected function compressSvg(string $file, array $args = []): bool
    {
        if (!$this->c::canCallFunc('exec')) {
            return false;
        }
        $default_args = [
            'precision'   => 0,
            'output_file' => '',
        ];
        $args += $default_args; // Defaults.

        if (!$file || !is_file($file)) {
            return false; // Not possible.
        }
        $args['precision'] = (int) ($args['precision'] ?: 4);
        $args['precision'] = max(1, min(8, $args['precision']));

        $args['output_file'] = (string) $args['output_file'];
        $args['output_file'] = $args['output_file'] ?: $file;

        $output_file_existed_prior = is_file($args['output_file']);

        $esc_file        = $this->c::escShellArg($file);
        $esc_precision   = $this->c::escShellArg($args['precision']);
        $esc_output_file = $this->c::escShellArg($args['output_file']);
        exec('svgo --quiet --precision='.$esc_precision.' --output='.$esc_output_file.' '.$esc_file, $_, $status);

        if ($status === 0) {
            return true; // Success.
        } else {
            if (!$output_file_existed_prior && is_file($args['output_file'])) {
                unlink($args['output_file']);
            }
            return false;
        }
    }
Compress SVG image.

@since 17xxxx Initial release.

@param string $file SVG file path.
@param array  $args Behavioral args.

@return bool True on success.

@see https://github.com/svg/svgo