Optimal character choices for ASCII art in PHP

Problem definition

ASCII art in PHP relies on the selection of a set of characters for the graphic representation. We didn’t find an optimal selection of characters mentioned anywhere. The example character sets seem to be chosen arbitrarily.

Approach

We consider as an acceptable approximation that the number of pixels used to display a font can be used to chose how dark/bright a character is in the ASCII art representation. With this, we use the 5 standard fonts within PHP to count the pixels for each ASCII character which decimal code is within (32-126). The result is the following for example for PHP font 5:

With no surprise, the minimum number of pixels is 0 for the space.

We divide the pixels space by the desired number of characters to find the best spread characters. We do this until we reach a situation where there is no character repetition. This occurs for for all fonts with sets of 9 characters.

PHP code

The following PHP code allowed to reach the desired outcome:

<?php
if(isset($argv[1]) && strlen($argv[1] && $argv[1]>1)) {
        $nbChars = $argv[1];
}else{
        echo "Please Specify a number of characters > 1\n";
        exit(1);
}
//$font must be 1-5
function nbPixelsForCharFont($char,$font){
	//inspired by https://www.php.net/manual/en/function.imagestring.php
	$h=15;
	$w=15;
	// Create a sized image
	$im = imagecreate($h, $w);

	// White background and black text
	$bg = imagecolorallocate($im, 255, 255, 255);
	$textcolor = imagecolorallocate($im, 0, 0, 0);

	// Write the string at the top left
	imagestring($im, $font, 0, 0, $char, $textcolor);
	$colorsSum=0;
	for($y=0;$y<$h;$y++){
		for($x=0;$x<$w;$x++){
			$color=imagecolorat ( $im , $x , $y );
			$colorsSum+=$color;
		}
	}
	imagedestroy($im);
	return($colorsSum);
}

function buildCharIntForNbPxArray($font){
        $charIntForNbPx=array();
        for($i=32;$i<127;$i++){
                $c=chr($i);
                $nbPx=nbPixelsForCharFont($c,$font);
		$charIntForNbPx[$nbPx]=$i;
        }
        ksort($charIntForNbPx);
        return($charIntForNbPx);
}

function findClosestKey($arr,$desiredKey,$reach=0){
	$r=(int)round($desiredKey);
	$high=$r+$reach;
	$last=array_key_last($arr);
	if($last>=$high&&array_key_exists($high,$arr))
		return($high);
	$low=$r-$reach;
	$first=array_key_first($arr);
        if($first<=$low&&array_key_exists($low,$arr))
                return($low);
	if($last>=$high||$first<=$low)
		return(findClosestKey($arr,$r,$reach+1));
	return(null);
}

function findBestChars($font,$nbChars){
	$bestChars=array();
	$charIntForNbPx=buildCharIntForNbPxArray($font);
	$minPx=array_key_first($charIntForNbPx);
	$maxPx=array_key_last($charIntForNbPx);
	$idealStep=($maxPx-$minPx)/($nbChars-1);
	for($i=$minPx;$i<=$maxPx;$i+=$idealStep){
		$key=findClosestKey($charIntForNbPx,$i);
		if(is_null($key))
			echo("Error, char shouldn't be null!\n");
		$bestChars[]=$charIntForNbPx[$key];
	}
	return($bestChars);
}

echo("Best chars for ascii art per PHP font for ".$nbChars." characters:\n");
for($font=1;$font<6;$font++){
	$prev=null;
	echo("font ".$font." best chars:\n");
	foreach(findBestChars($font,$nbChars) as $char){
		echo($char.":".chr($char)."\n");
		if($prev==$char)
			echo("ALERT!!! same as previous!!!\n");
		$prev=$char;
	}
	echo("\n");
}
?>

Outcome

The outcome is the following table of optimized character sets:

Font 1Font 2Font 3Font 4Font 5
32:  32:  32:  32:  32:  
94:^96:`46:.46:.96:`
95:_34:”96:`58::94:^
120:x59:;33:!114:r124:|
125:}118:v63:?108:l49:1
71:G122:z120:x70:F97:a
81:Q121:y121:y109:m85:U
64:@72:H87:W82:R66:B
35:#87:W78:N81:Q78:N

Comparison

To compare the sets, we used the following PHP code inspired by this page:

<?php
if(isset($argv[1]) && strlen($argv[1])) {
	$file = $argv[1];
}else{
	echo "Please Specify a file\n";
	exit(1);
}

$img = imagecreatefromstring(file_get_contents($file));
list($width, $height) = getimagesize($file);

$scale = 10;

//characters list from http://paulbourke.net/dataformats/asciiart/
$chars=[
'@',
'%',
'#',
'*',
'+',
'=',
'-',
':',
'.',
' '
];

$c_count = count($chars);

//algorithm from https://gist.github.com/donatj/1353237
for($y = 0; $y <= $height - $scale - 1; $y += $scale) {
	for($x = 0; $x <= $width - ($scale / 2) - 1; $x += ($scale / 2)) {
		$rgb = imagecolorat($img, $x, $y);
		$r = (($rgb >> 16) & 0xFF);
		$g = (($rgb >> 8) & 0xFF);
		$b = ($rgb & 0xFF);
		$sat = ($r + $g + $b) / (255 * 3);
		echo $chars[ (int)( $sat * ($c_count - 1) ) ];
	}
	echo PHP_EOL;
}
?>

Here is the original image for the comparison:

The resulting ASCII art based on the short character set on this page is:

$chars=['@','%','#','*','+','=','-',':','.',' '];

++==+=+++++++++++++++++=--::::==++****+#**+*+********+***++**+******#
=++++++++++++++++++++++:::::--.:--+++++*+++++++++++++++++++++++++++**
==+====++==++========+++=+=::::-=+++++#%+++++++++++++++++++++++++++++
=====+====--......:-==---:-:...:=++++*#%%+++++++++++++++++++++++++++*
. :=====-:  ........::::::-:..::-+++#%#%%%#++++++++++++++++++++++++++
.....====-.....::-:.:. .....:-:=+=+#%%%%%%%#+++++++++++++++++++++++++
......-==:.. ..:-=:.........:. ..-#%%@@@@%%%%*+++++++++++++++++++++++
:.....:===......::.    ....... .:#%@@@%@@@@@%%#=+++++++++++++++++++++
:......===...           ..   ..:#@@@%%%@@@@@@@%%=++++++++++++++++++++
.......:..  .             ..-%@@%%##*#%@@@@@@@@@@@%%*++++++++++++++++
:::--:..       .......... .=%%%**#####%@@@@@@@@@@@%#+++++++++++++++++
====-:....   .....--::::...:*##*+#*####@@@@@@@@@@@@#+++++++++++++++++
======-:..........:::......:*#%**###**#@@@@@@@@@@@@%=-==+++++++++++++
=======-:::................=%%#+***%*##@@@@@@@@@@@%%+=++++++=.:.....:
+=========-:.::.:.:::+%#%@@@%@%++*##*##@@@@%@@@@@@%%+==+==++=-:::::::
===-=-======---::+###++*@@@@@@%++++**##@@@@@%@@@@@@%=:.:---====---:::
=----========+#*%+=+++++@@@@%%%***#**##%@@@@@@@@@@%%+:::---=++====---
=-----=--=###*++++++*+*#@@@@@@%******##@@@@@@@@%@@@%*================
-:...:##%*+++*****=#+++#@@@@@@%#*#%%%##%@@@%%@%%@%@%#-=======+=======
-..*#++*+***+#=+#******#@@@@@@@%***#*##%@@@%@@%@@%@%%-==-==========-=
:..-***#*++*+**********#@@@@@@%%*+***##%@@@@@@%@@@@%%+---=-===--=====
:..#*+****+********###*#@@@@@@@%*+*#*##%@@@%@@@%%@@%%*-------------==
#@@@@@@@@@@#*#***#%@%**#@@@@@@@#*@%**###@@@@@@@@@@@@%*-------------==
#@@@@@@@@@@#@%**+*@@%*##@@@@@@@@@@@@*###@@@@@@@@@@@@%#::::::::-------
##*+**#@@@@#@%+=+*@@%*#%@@@@@@@@@@@@*###@@@@@@@@@@@@@%-:--::---------
#%#**+*%%#@%@%+++*%%%*#%@@@@@@@@@@@@####@@@@@@%@@@@@%%--:-----------=
#%#%++*%%%@@%%***#%#%##%@@@@@@@%@@@@*###@@@@@@@@@@@@@%=+-----------==
#%#%+**%%@@%*##########@@@@@@@@@@@@@###*@@@@@@@@@@@@@@@#%#---+=======
++=+***#*@@#+**##**####@@@@@@@@@%%%%#***@@@@@@@@@@@@@@@@@@%#**%%#**+*
+*+*+*********####**%%%@@@@@##**+*#%*#*#@@@@@@@@%@@@@@@@%%%%%%@@@@%##
********+++++*+++++++=+=====++++*#######@@@@@@@#%%%%@@@@%@%%%#%%@@@@#
*********+****+*+++====--===+=--===+++++++=++++**#####**##%@@@@@@@@@@
*+**+*+****+++*+*++++++++*+****+*******+++******+*********+****+*****
***********+++++++*+*====+=+++++=+++*+++++*+++****+*+****##**********

With php font 1 character set, we get this:

$chars=['#','@','Q','G','}','x','_','^',' '];
G}}}}}}}G}G}GGGGGGGGGGGxx_____x}}GGGGGGQGGGGGGGGGGGGGGGGGGGGGGGGGGGQQ
x}}}}}}}}}}}}}}}}}}}}}}___^^_x^__x}}}}GG}}}}}}GGGGGG}GGGGGGGGGGGGGGGG
}x}}}}}}}}}}}}}}}}}}}}}}}}}____xx}}}}}Q@G}}}}}G}}}}GGGGGGGGGGGGGGGGGG
x}}}}}}}}}x_^^^^^^_x}}xx__x_^^^_}}}}}G@@@G}}}}}}}}}}GGGGGGGGGGGGGGGGG
^ _}}}}}x^  ^^^^^^^^____^___^^__x}}}Q@@@@@Q}}}}}}}}}}}}}}GGGGGGGGGGGG
^^^^^}}}}x^^^^^__x_^_^ ^^^^^___x}}}@@@@@#@@Q}}}}}}}}}}}}G}GGGG}GGGGGG
^^^^^^x}}_^^ ^^_xx_^^^^^^^^^_^ ^^_@@@####@@@@G}}}}}}}}}}}}}}}}}}}GGGG
^^^^^^_}}}^^^^^^_^^    ^^^^^^^ ^_@@###@#####@@Q}}}}}}}}}}}}}}}}}GG}GG
^^^^^^^x}}^^^           ^^   ^^_@###@@@#######@@}}}}}}}}}}}G}}}}}}GGG
^^^^^^^_^^  ^             ^^x@###@QQQ@@############@Q}}}}}}}}}}G}}GG}
____x_^^       ^^^^^^^^^^ ^}@@@QG@QQQQ@############Q}}}}}}}}}}}}}}}}}
x}}}x_^^^^   ^^^^^xx____^^^^QQQGG@QQQQ@############@}}}}}}}}}}}}}}}}}
}}}}}}x_^^^^^^^^^^___^^^^^^_QQ@GGQQQQQQ############@xx}}}}}}}}}}}}}}}
}}}}}}xx___^^^^^^^^^^^^^^^^}@#@GGGQ@QQQ###########@@}}}}}}}}}^_^^^^^^
}}}xx}x}}xx_^^_^^^^__G@Q@###@#@GGG@QGQQ############@}}}}}}}}}x_______
}}}x}xx}}x}}xx___}@Q@G}G######@GG}GQGQQ############@}_^_x_x}}}xxx____
}xxxxxx}}x}x}GQG@G}}GG}G######@GGGQGGQQ@##########@@G____xx}}}}}}}xxx
}xxxxxxxx}QQ@QG}}}GGQ}GQ######@QQGGGQQ@############@Q}}}}}}}}}}}xxxx}
_^^^^_Q@@GGGGGQGGG}QG}GQ#######QQ@@@@QQ@###@@#@@#@#@@x}}}}x}x}}}xxxxx
x^^G@GGGGGGGGQ}}QGGQGGQQ#######@GGQQGQQ@#########@#@@x}xx}xx}xxxx}xxx
_^^xGGGQG}GGGGGGGGGGGGQQ#######@GGGGQQQ@###########@@}xxxxxx}}xxxxxxx
_^^QGGGGGQGQGQQGQGQQQQQQ#######@GGQQQQQ@########@##@@Gxxxxxxxxxxxxxxx
Q##########QQQGQQQ##@QGQ#######@G#@QQQQ@############@Q___xx_xxx_xxxxx
Q##########Q#@QGGG##@QQQ############G@QQ############@Q_________xxxxxx
QQQGGGQ####@#@G}GQ##@QQ@############QQQQ#############@_______xxxxxxxx
Q@QGQ}G@@@#@#@GGGQ##@QQ@############QQQQ######@#####@@x_______xxxxxxx
Q@Q@}GG@@@##@@QGQQ@Q@QQ@############GQQQ#############@}}x___xxxxxxxxx
Q@Q@}GQ@@##@GQQQQQQQQQQ#############QQQQ###############@@@xxx}}}xxxx}
G}}}GQQQG##QGQQQQGQQQQQ#########@@##QGQQ###################QQG@@QQGGG
GGGGGGGGGGQGGQQQQQQQ@@######QQGGGQQ@GQQQ################@@@@@@####@Q@
GGGGGGGGGGG}GGGGGGGG}}}}xx}}}}GGQQQQQQQQ#######@@@#@####@##@@Q@@####Q
GQQQQQGGGGGGGQGGGG}}}}xxxx}}}}xxx}}}}}GG}G}GGGGGGQQQQQGGQ@@##########
GGGGGGGGGGGGGGGGGGGGGGG}GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
GGGGGGGGGGGGG}GGGGGGG}}}}}}}}GG}}GGGGGGGGGGGGGGGGGGGGQGQQQQGGGQGGGGGG

With php font 2 character set, we get this:

$chars=['W','H','y','z','v',';','"','`',' '];
zvvvvvvvzvzvzzzzzzzzzzz;;""""";vvzzzzzzyzzzzzzzzzzzzzzzzzzzzzzzzzzzyy
;vvvvvvvvvvvvvvvvvvvvvv"""``";`"";vvvvzzvvvvvvzzzzzzvzzzzzzzzzzzzzzzz
v;vvvvvvvvvvvvvvvvvvvvvvvvv"""";;vvvvvyHzvvvvvzvvvvzzzzzzzzzzzzzzzzzz
;vvvvvvvvv;"``````";vv;;"";"```"vvvvvzHHHzvvvvvvvvvvzzzzzzzzzzzzzzzzz
` "vvvvv;`  ````````""""`"""``"";vvvyHHHHHyvvvvvvvvvvvvvvzzzzzzzzzzzz
`````vvvv;`````"";"`"` `````""";vvvHHHHHWHHyvvvvvvvvvvvvzvzzzzvzzzzzz
``````;vv"`` ``";;"`````````"` ``"HHHWWWWHHHHzvvvvvvvvvvvvvvvvvvvzzzz
``````"vvv``````"``    ``````` `"HHWWWHWWWWWHHyvvvvvvvvvvvvvvvvvzzvzz
```````;vv```           ``   ``"HWWWHHHWWWWWWWHHvvvvvvvvvvvzvvvvvvzzz
```````"``  `             ``;HWWWHyyyHHWWWWWWWWWWWWHyvvvvvvvvvvzvvzzv
"""";"``       `````````` `vHHHyzHyyyyHWWWWWWWWWWWWyvvvvvvvvvvvvvvvvv
;vvv;"````   `````;;""""````yyyzzHyyyyHWWWWWWWWWWWWHvvvvvvvvvvvvvvvvv
vvvvvv;"``````````"""``````"yyHzzyyyyyyWWWWWWWWWWWWH;;vvvvvvvvvvvvvvv
vvvvvv;;"""````````````````vHWHzzzyHyyyWWWWWWWWWWWHHvvvvvvvvv`"``````
vvv;;v;vv;;"``"````""zHyHWWWHWHzzzHyzyyWWWWWWWWWWWWHvvvvvvvvv;"""""""
vvv;v;;vv;vv;;"""vHyHzvzWWWWWWHzzvzyzyyWWWWWWWWWWWWHv"`";";vvv;;;""""
v;;;;;;vv;v;vzyzHzvvzzvzWWWWWWHzzzyzzyyHWWWWWWWWWWHHz"""";;vvvvvvv;;;
v;;;;;;;;vyyHyzvvvzzyvzyWWWWWWHyyzzzyyHWWWWWWWWWWWWHyvvvvvvvvvvv;;;;v
"````"yHHzzzzzyzzzvyzvzyWWWWWWWyyHHHHyyHWWWHHWHHWHWHH;vvvv;v;vvv;;;;;
;``zHzzzzzzzzyvvyzzyzzyyWWWWWWWHzzyyzyyHWWWWWWWWWHWHH;v;;v;;v;;;;v;;;
"``;zzzyzvzzzzzzzzzzzzyyWWWWWWWHzzzzyyyHWWWWWWWWWWWHHv;;;;;;vv;;;;;;;
"``yzzzzzyzyzyyzyzyyyyyyWWWWWWWHzzyyyyyHWWWWWWWWHWWHHz;;;;;;;;;;;;;;;
yWWWWWWWWWWyyyzyyyWWHyzyWWWWWWWHzWHyyyyHWWWWWWWWWWWWHy""";;";;;";;;;;
yWWWWWWWWWWyWHyzzzWWHyyyWWWWWWWWWWWWzHyyWWWWWWWWWWWWHy""""""""";;;;;;
yyyzzzyWWWWHWHzvzyWWHyyHWWWWWWWWWWWWyyyyWWWWWWWWWWWWWH""""""";;;;;;;;
yHyzyvzHHHWHWHzzzyWWHyyHWWWWWWWWWWWWyyyyWWWWWWHWWWWWHH;""""""";;;;;;;
yHyHvzzHHHWWHHyzyyHyHyyHWWWWWWWWWWWWzyyyWWWWWWWWWWWWWHvv;""";;;;;;;;;
yHyHvzyHHWWHzyyyyyyyyyyWWWWWWWWWWWWWyyyyWWWWWWWWWWWWWWWHHH;;;vvv;;;;v
zvvvzyyyzWWyzyyyyzyyyyyWWWWWWWWWHHWWyzyyWWWWWWWWWWWWWWWWWWWyyzHHyyzzz
zzzzzzzzzzyzzyyyyyyyHHWWWWWWyyzzzyyHzyyyWWWWWWWWWWWWWWWWHHHHHHWWWWHyH
zzzzzzzzzzzvzzzzzzzzvvvv;;vvvvzzyyyyyyyyWWWWWWWHHHWHWWWWHWWHHyHHWWWWy
zyyyyyzzzzzzzyzzzzvvvv;;;;vvvv;;;vvvvvzzvzvzzzzzzyyyyyzzyHHWWWWWWWWWW
zzzzzzzzzzzzzzzzzzzzzzzvzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
zzzzzzzzzzzzzvzzzzzzzvvvvvvvvzzvvzzzzzzzzzzzzzzzzzzzzyzyyyyzzzyzzzzzz

With php font 3 character set, we get this:

$chars=['N','W','y','x','?','!','`','.',' '];
x???????x?x?xxxxxxxxxxx!!`````!??xxxxxxyxxxxxxxxxxxxxxxxxxxxxxxxxxxyy
!??????????????????????```..`!.``!????xx??????xxxxxx?xxxxxxxxxxxxxxxx
?!?????????????????????????````!!?????yWx?????x????xxxxxxxxxxxxxxxxxx
!?????????!`......`!??!!``!`...`?????xWWWx??????????xxxxxxxxxxxxxxxxx
. `?????!.  ........````.```..``!???yWWWWWy??????????????xxxxxxxxxxxx
.....????!.....``!`.`. .....```!???WWWWWNWWy????????????x?xxxx?xxxxxx
......!??`.. ..`!!`.........`. ..`WWWNNNNWWWWx???????????????????xxxx
......`???......`..    ....... .`WWNNNWNNNNNWWy?????????????????xx?xx
.......!??...           ..   ..`WNNNWWWNNNNNNNWW???????????x??????xxx
.......`..  .             ..!WNNNWyyyWWNNNNNNNNNNNNWy??????????x??xx?
````!`..       .......... .?WWWyxWyyyyWNNNNNNNNNNNNy?????????????????
!???!`....   .....!!````....yyyxxWyyyyWNNNNNNNNNNNNW?????????????????
??????!`..........```......`yyWxxyyyyyyNNNNNNNNNNNNW!!???????????????
??????!!```................?WNWxxxyWyyyNNNNNNNNNNNWW?????????.`......
???!!?!??!!`..`....``xWyWNNNWNWxxxWyxyyNNNNNNNNNNNNW?????????!```````
???!?!!??!??!!```?WyWx?xNNNNNNWxx?xyxyyNNNNNNNNNNNNW?`.`!`!???!!!````
?!!!!!!??!?!?xyxWx??xx?xNNNNNNWxxxyxxyyWNNNNNNNNNNWWx````!!???????!!!
?!!!!!!!!?yyWyx???xxy?xyNNNNNNWyyxxxyyWNNNNNNNNNNNNWy???????????!!!!?
`....`yWWxxxxxyxxx?yx?xyNNNNNNNyyWWWWyyWNNNWWNWWNWNWW!????!?!???!!!!!
!..xWxxxxxxxxy??yxxyxxyyNNNNNNNWxxyyxyyWNNNNNNNNNWNWW!?!!?!!?!!!!?!!!
`..!xxxyx?xxxxxxxxxxxxyyNNNNNNNWxxxxyyyWNNNNNNNNNNNWW?!!!!!!??!!!!!!!
`..yxxxxxyxyxyyxyxyyyyyyNNNNNNNWxxyyyyyWNNNNNNNNWNNWWx!!!!!!!!!!!!!!!
yNNNNNNNNNNyyyxyyyNNWyxyNNNNNNNWxNWyyyyWNNNNNNNNNNNNWy```!!`!!!`!!!!!
yNNNNNNNNNNyNWyxxxNNWyyyNNNNNNNNNNNNxWyyNNNNNNNNNNNNWy`````````!!!!!!
yyyxxxyNNNNWNWx?xyNNWyyWNNNNNNNNNNNNyyyyNNNNNNNNNNNNNW```````!!!!!!!!
yWyxy?xWWWNWNWxxxyNNWyyWNNNNNNNNNNNNyyyyNNNNNNWNNNNNWW!```````!!!!!!!
yWyW?xxWWWNNWWyxyyWyWyyWNNNNNNNNNNNNxyyyNNNNNNNNNNNNNW??!```!!!!!!!!!
yWyW?xyWWNNWxyyyyyyyyyyNNNNNNNNNNNNNyyyyNNNNNNNNNNNNNNNWWW!!!???!!!!?
x???xyyyxNNyxyyyyxyyyyyNNNNNNNNNWWNNyxyyNNNNNNNNNNNNNNNNNNNyyxWWyyxxx
xxxxxxxxxxyxxyyyyyyyWWNNNNNNyyxxxyyWxyyyNNNNNNNNNNNNNNNNWWWWWWNNNNWyW
xxxxxxxxxxx?xxxxxxxx????!!????xxyyyyyyyyNNNNNNNWWWNWNNNNWNNWWyWWNNNNy
xyyyyyxxxxxxxyxxxx????!!!!????!!!?????xx?x?xxxxxxyyyyyxxyWWNNNNNNNNNN
xxxxxxxxxxxxxxxxxxxxxxx?xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxx?xxxxxxx????????xx??xxxxxxxxxxxxxxxxxxxxyxyyyyxxxyxxxxxx

With php font 4 character set, we get this:

$chars=['Q','R','m','F','l','r',':','.',' '];
FlllllllFlFlFFFFFFFFFFFrr:::::rllFFFFFFmFFFFFFFFFFFFFFFFFFFFFFFFFFFmm
rllllllllllllllllllllll:::..:r.::rllllFFllllllFFFFFFlFFFFFFFFFFFFFFFF
lrlllllllllllllllllllllllll::::rrlllllmRFlllllFllllFFFFFFFFFFFFFFFFFF
rlllllllllr:......:rllrr::r:...:lllllFRRRFllllllllllFFFFFFFFFFFFFFFFF
. :lllllr.  ........::::.:::..::rlllmRRRRRmllllllllllllllFFFFFFFFFFFF
.....llllr.....::r:.:. .....:::rlllRRRRRQRRmllllllllllllFlFFFFlFFFFFF
......rll:.. ..:rr:.........:. ..:RRRQQQQRRRRFlllllllllllllllllllFFFF
......:lll......:..    ....... .:RRQQQRQQQQQRRmlllllllllllllllllFFlFF
.......rll...           ..   ..:RQQQRRRQQQQQQQRRlllllllllllFllllllFFF
.......:..  .             ..rRQQQRmmmRRQQQQQQQQQQQQRmllllllllllFllFFl
::::r:..       .......... .lRRRmFRmmmmRQQQQQQQQQQQQmlllllllllllllllll
rlllr:....   .....rr::::....mmmFFRmmmmRQQQQQQQQQQQQRlllllllllllllllll
llllllr:..........:::......:mmRFFmmmmmmQQQQQQQQQQQQRrrlllllllllllllll
llllllrr:::................lRQRFFFmRmmmQQQQQQQQQQQRRlllllllll.:......
lllrrlrllrr:..:....::FRmRQQQRQRFFFRmFmmQQQQQQQQQQQQRlllllllllr:::::::
lllrlrrllrllrr:::lRmRFlFQQQQQQRFFlFmFmmQQQQQQQQQQQQRl:.:r:rlllrrr::::
lrrrrrrllrlrlFmFRFllFFlFQQQQQQRFFFmFFmmRQQQQQQQQQQRRF::::rrlllllllrrr
lrrrrrrrrlmmRmFlllFFmlFmQQQQQQRmmFFFmmRQQQQQQQQQQQQRmlllllllllllrrrrl
:....:mRRFFFFFmFFFlmFlFmQQQQQQQmmRRRRmmRQQQRRQRRQRQRRrllllrlrlllrrrrr
r..FRFFFFFFFFmllmFFmFFmmQQQQQQQRFFmmFmmRQQQQQQQQQRQRRrlrrlrrlrrrrlrrr
:..rFFFmFlFFFFFFFFFFFFmmQQQQQQQRFFFFmmmRQQQQQQQQQQQRRlrrrrrrllrrrrrrr
:..mFFFFFmFmFmmFmFmmmmmmQQQQQQQRFFmmmmmRQQQQQQQQRQQRRFrrrrrrrrrrrrrrr
mQQQQQQQQQQmmmFmmmQQRmFmQQQQQQQRFQRmmmmRQQQQQQQQQQQQRm:::rr:rrr:rrrrr
mQQQQQQQQQQmQRmFFFQQRmmmQQQQQQQQQQQQFRmmQQQQQQQQQQQQRm:::::::::rrrrrr
mmmFFFmQQQQRQRFlFmQQRmmRQQQQQQQQQQQQmmmmQQQQQQQQQQQQQR:::::::rrrrrrrr
mRmFmlFRRRQRQRFFFmQQRmmRQQQQQQQQQQQQmmmmQQQQQQRQQQQQRRr:::::::rrrrrrr
mRmRlFFRRRQQRRmFmmRmRmmRQQQQQQQQQQQQFmmmQQQQQQQQQQQQQRllr:::rrrrrrrrr
mRmRlFmRRQQRFmmmmmmmmmmQQQQQQQQQQQQQmmmmQQQQQQQQQQQQQQQRRRrrrlllrrrrl
FlllFmmmFQQmFmmmmFmmmmmQQQQQQQQQRRQQmFmmQQQQQQQQQQQQQQQQQQQmmFRRmmFFF
FFFFFFFFFFmFFmmmmmmmRRQQQQQQmmFFFmmRFmmmQQQQQQQQQQQQQQQQRRRRRRQQQQRmR
FFFFFFFFFFFlFFFFFFFFllllrrllllFFmmmmmmmmQQQQQQQRRRQRQQQQRQQRRmRRQQQQm
FmmmmmFFFFFFFmFFFFllllrrrrllllrrrlllllFFlFlFFFFFFmmmmmFFmRRQQQQQQQQQQ
FFFFFFFFFFFFFFFFFFFFFFFlFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFlFFFFFFFllllllllFFllFFFFFFFFFFFFFFFFFFFFmFmmmmFFFmFFFFFF

With php font 5 character set, we get this:

$chars=['N','B','U','a','1','|','^','`',' '];
a1111111a1a1aaaaaaaaaaa||^^^^^|11aaaaaaUaaaaaaaaaaaaaaaaaaaaaaaaaaaUU
|1111111111111111111111^^^``^|`^^|1111aa111111aaaaaa1aaaaaaaaaaaaaaaa
1|1111111111111111111111111^^^^||11111UBa11111a1111aaaaaaaaaaaaaaaaaa
|111111111|^``````^|11||^^|^```^11111aBBBa1111111111aaaaaaaaaaaaaaaaa
` ^11111|`  ````````^^^^`^^^``^^|111UBBBBBU11111111111111aaaaaaaaaaaa
`````1111|`````^^|^`^` `````^^^|111BBBBBNBBU111111111111a1aaaa1aaaaaa
``````|11^`` ``^||^`````````^` ``^BBBNNNNBBBBa1111111111111111111aaaa
``````^111``````^``    ``````` `^BBNNNBNNNNNBBU11111111111111111aa1aa
```````|11```           ``   ``^BNNNBBBNNNNNNNBB11111111111a111111aaa
```````^``  `             ``|BNNNBUUUBBNNNNNNNNNNNNBU1111111111a11aa1
^^^^|^``       `````````` `1BBBUaBUUUUBNNNNNNNNNNNNU11111111111111111
|111|^````   `````||^^^^````UUUaaBUUUUBNNNNNNNNNNNNB11111111111111111
111111|^``````````^^^``````^UUBaaUUUUUUNNNNNNNNNNNNB||111111111111111
111111||^^^````````````````1BNBaaaUBUUUNNNNNNNNNNNBB111111111`^``````
111||1|11||^``^````^^aBUBNNNBNBaaaBUaUUNNNNNNNNNNNNB111111111|^^^^^^^
111|1||11|11||^^^1BUBa1aNNNNNNBaa1aUaUUNNNNNNNNNNNNB1^`^|^|111|||^^^^
1||||||11|1|1aUaBa11aa1aNNNNNNBaaaUaaUUBNNNNNNNNNNBBa^^^^||1111111|||
1||||||||1UUBUa111aaU1aUNNNNNNBUUaaaUUBNNNNNNNNNNNNBU11111111111||||1
^````^UBBaaaaaUaaa1Ua1aUNNNNNNNUUBBBBUUBNNNBBNBBNBNBB|1111|1|111|||||
|``aBaaaaaaaaU11UaaUaaUUNNNNNNNBaaUUaUUBNNNNNNNNNBNBB|1||1||1||||1|||
^``|aaaUa1aaaaaaaaaaaaUUNNNNNNNBaaaaUUUBNNNNNNNNNNNBB1||||||11|||||||
^``UaaaaaUaUaUUaUaUUUUUUNNNNNNNBaaUUUUUBNNNNNNNNBNNBBa|||||||||||||||
UNNNNNNNNNNUUUaUUUNNBUaUNNNNNNNBaNBUUUUBNNNNNNNNNNNNBU^^^||^|||^|||||
UNNNNNNNNNNUNBUaaaNNBUUUNNNNNNNNNNNNaBUUNNNNNNNNNNNNBU^^^^^^^^^||||||
UUUaaaUNNNNBNBa1aUNNBUUBNNNNNNNNNNNNUUUUNNNNNNNNNNNNNB^^^^^^^||||||||
UBUaU1aBBBNBNBaaaUNNBUUBNNNNNNNNNNNNUUUUNNNNNNBNNNNNBB|^^^^^^^|||||||
UBUB1aaBBBNNBBUaUUBUBUUBNNNNNNNNNNNNaUUUNNNNNNNNNNNNNB11|^^^|||||||||
UBUB1aUBBNNBaUUUUUUUUUUNNNNNNNNNNNNNUUUUNNNNNNNNNNNNNNNBBB|||111||||1
a111aUUUaNNUaUUUUaUUUUUNNNNNNNNNBBNNUaUUNNNNNNNNNNNNNNNNNNNUUaBBUUaaa
aaaaaaaaaaUaaUUUUUUUBBNNNNNNUUaaaUUBaUUUNNNNNNNNNNNNNNNNBBBBBBNNNNBUB
aaaaaaaaaaa1aaaaaaaa1111||1111aaUUUUUUUUNNNNNNNBBBNBNNNNBNNBBUBBNNNNU
aUUUUUaaaaaaaUaaaa1111||||1111|||11111aa1a1aaaaaaUUUUUaaUBBNNNNNNNNNN
aaaaaaaaaaaaaaaaaaaaaaa1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaa1aaaaaaa11111111aa11aaaaaaaaaaaaaaaaaaaaUaUUUUaaaUaaaaaa

Here are the same as images:

Example set
Font 1 set
Font 2 set
Font 3 set
Font 4 set
Font 5 set

Our favorite is the font 5 set.

Adaptations

As the ASCII art representation depends on the selected font, the above explained approach can be adapted to the situation. Also, the number of characters can easily be either increased or decreased.

Leave a comment

Your email address will not be published.