mirror of
https://github.com/mosbth/cimage.git
synced 2025-08-10 18:14:25 +02:00
Adding support for AsciiArt of an image.
This commit is contained in:
@@ -754,11 +754,55 @@ verbose("filters = " . print_r($filters, 1));
|
||||
|
||||
|
||||
/**
|
||||
* json - output the image as a JSON object with details on the image.
|
||||
* json - output the image as a JSON object with details on the image.
|
||||
* ascii - output the image as ASCII art.
|
||||
*/
|
||||
$outputFormat = getDefined('json', 'json', null);
|
||||
$outputFormat = getDefined('ascii', 'ascii', $outputFormat);
|
||||
|
||||
verbose("outputformat = $outputFormat");
|
||||
|
||||
if ($outputFormat == 'ascii') {
|
||||
$defaultOptions = getConfig(
|
||||
'ascii-options',
|
||||
array(
|
||||
"characterSet" => 'two',
|
||||
"scale" => 14,
|
||||
"luminanceStrategy" => 3,
|
||||
"customCharacterSet" => null,
|
||||
)
|
||||
);
|
||||
$options = get('ascii');
|
||||
$options = explode(',', $options);
|
||||
|
||||
if (isset($options[0]) && !empty($options[0])) {
|
||||
$defaultOptions['characterSet'] = $options[0];
|
||||
}
|
||||
|
||||
if (isset($options[1]) && !empty($options[1])) {
|
||||
$defaultOptions['scale'] = $options[1];
|
||||
}
|
||||
|
||||
if (isset($options[2]) && !empty($options[2])) {
|
||||
$defaultOptions['luminanceStrategy'] = $options[2];
|
||||
}
|
||||
|
||||
if (count($options) > 3) {
|
||||
// Last option is custom character string
|
||||
unset($options[0]);
|
||||
unset($options[1]);
|
||||
unset($options[2]);
|
||||
$characterString = implode($options);
|
||||
$defaultOptions['customCharacterSet'] = $characterString;
|
||||
}
|
||||
|
||||
//var_dump($options);
|
||||
//var_dump($defaultOptions);
|
||||
//exit;
|
||||
|
||||
$img->setAsciiOptions($defaultOptions);
|
||||
}
|
||||
|
||||
verbose("json = $outputFormat");
|
||||
|
||||
|
||||
|
||||
|
@@ -299,4 +299,25 @@ return array(
|
||||
'golden' => 1.618,
|
||||
);
|
||||
},*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* default options for ascii image.
|
||||
*
|
||||
* Default values as specified below in the array.
|
||||
* ascii-options:
|
||||
* characterSet: Choose any character set available in CAsciiArt.
|
||||
* scale: How many pixels should each character
|
||||
* translate to.
|
||||
* luminanceStrategy: Choose any strategy available in CAsciiArt.
|
||||
* customCharacterSet: Define your own character set.
|
||||
*/
|
||||
/*'ascii-options' => array(
|
||||
"characterSet" => 'two',
|
||||
"scale" => 14,
|
||||
"luminanceStrategy" => 3,
|
||||
"customCharacterSet" => null,
|
||||
);
|
||||
},*/
|
||||
);
|
||||
|
Reference in New Issue
Block a user