public function identipattern(array $args): bool
    {
        if (!class_exists('Imagick')) {
            return false;
        }
        $default_args = [
            'string' => '',
            'for'    => '',

            'color'      => '',
            'base_color' => '',

            'output_file'   => '',
            'output_format' => '',
        ];
        $args += $default_args; // Defaults.
        $args = $this->parseFormatArgs($args);

        if (!$args['output_file'] || !$args['output_format']) {
            return false; // Required arguments.
        }
        $args['string'] = (string) $args['string'];
        $args['string'] = $args['string'] ?: (string) $args['for'];

        $args['color']      = (string) $args['color'];
        $args['base_color'] = (string) $args['base_color'];

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

        try { // Catch exceptions.
            $svg = (new Identipattern([
                'string'    => $args['string'] ?: null,
                'baseColor' => $args['base_color'] ?: null,
                'color'     => $args['color'] ?: null,
            ]))->toSVG(); // SVG format initially.

            if (file_put_contents($args['output_file'], $svg) === false) {
                throw $this->c::issue('Storage failure.');
            }
            if ($args['output_format'] !== 'svg') {
                if (!$this->convert([
                        'format' => 'svg',
                        'file'   => $args['output_file'],

                        'output_file'   => $args['output_file'],
                        'output_format' => $args['output_format'],
                    ])) {
                    throw $this->c::issue('Conversion failure.');
                }
            }
            return true; // Success.
            //
        } catch (\Throwable $Exception) {
            if (!$output_file_existed_prior && is_file($args['output_file'])) {
                unlink($args['output_file']);
            }
            return false;
        }
    }
public function identipattern(array $args): bool
    {
        if (!class_exists('Imagick')) {
            return false;
        }
        $default_args = [
            'string' => '',
            'for'    => '',

            'color'      => '',
            'base_color' => '',

            'output_file'   => '',
            'output_format' => '',
        ];
        $args += $default_args; // Defaults.
        $args = $this->parseFormatArgs($args);

        if (!$args['output_file'] || !$args['output_format']) {
            return false; // Required arguments.
        }
        $args['string'] = (string) $args['string'];
        $args['string'] = $args['string'] ?: (string) $args['for'];

        $args['color']      = (string) $args['color'];
        $args['base_color'] = (string) $args['base_color'];

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

        try { // Catch exceptions.
            $svg = (new Identipattern([
                'string'    => $args['string'] ?: null,
                'baseColor' => $args['base_color'] ?: null,
                'color'     => $args['color'] ?: null,
            ]))->toSVG(); // SVG format initially.

            if (file_put_contents($args['output_file'], $svg) === false) {
                throw $this->c::issue('Storage failure.');
            }
            if ($args['output_format'] !== 'svg') {
                if (!$this->convert([
                        'format' => 'svg',
                        'file'   => $args['output_file'],

                        'output_file'   => $args['output_file'],
                        'output_format' => $args['output_format'],
                    ])) {
                    throw $this->c::issue('Conversion failure.');
                }
            }
            return true; // Success.
            //
        } catch (\Throwable $Exception) {
            if (!$output_file_existed_prior && is_file($args['output_file'])) {
                unlink($args['output_file']);
            }
            return false;
        }
    }
public function identipattern ( array $ args ) : bool { if ( ! class_exists ( 'Imagick' ) ) { return false ; } $ default_args = [ 'string' => '' , 'for' => '' , 'color' => '' , 'base_color' => '' , 'output_file' => '' , 'output_format' => '' , ] ; $ args += $ default_args ; // Defaults. $ args = $ this -> parseFormatArgs ( $ args ) ; if ( ! $ args [ 'output_file' ] || ! $ args [ 'output_format' ] ) { return false ; // Required arguments. } $ args [ 'string' ] = ( string ) $ args [ 'string' ] ; $ args [ 'string' ] = $ args [ 'string' ] ? : ( string ) $ args [ 'for' ] ; $ args [ 'color' ] = ( string ) $ args [ 'color' ] ; $ args [ 'base_color' ] = ( string ) $ args [ 'base_color' ] ; $ output_file_existed_prior = is_file ( $ args [ 'output_file' ] ) ; try { // Catch exceptions. $ svg = ( new Identipattern ( [ 'string' => $ args [ 'string' ] ? : null , 'baseColor' => $ args [ 'base_color' ] ? : null , 'color' => $ args [ 'color' ] ? : null , ] ) ) -> toSVG ( ) ; // SVG format initially. if ( file_put_contents ( $ args [ 'output_file' ] , $ svg ) === false ) { throw $ this -> c :: issue ( 'Storage failure.' ) ; } if ( $ args [ 'output_format' ] !== 'svg' ) { if ( ! $ this -> convert ( [ 'format' => 'svg' , 'file' => $ args [ 'output_file' ] , 'output_file' => $ args [ 'output_file' ] , 'output_format' => $ args [ 'output_format' ] , ] ) ) { throw $ this -> c :: issue ( 'Conversion failure.' ) ; } } return true ; // Success. // } catch ( \ Throwable $ Exception ) { if ( ! $ output_file_existed_prior && is_file ( $ args [ 'output_file' ] ) ) { unlink ( $ args [ 'output_file' ] ) ; } return false ; } }
Identipattern generator.

@since 17xxxx Identipatterns.

@param array $args Named arguments.

@return bool True on success.
Identipattern generator .