Skip to content

fix(post): remove max_chars budget cap for ASCII art#16

Open
thedarkknight197 wants to merge 2 commits into
ferdinandobons:mainfrom
thedarkknight197:fix/img-art-no-char-budget
Open

fix(post): remove max_chars budget cap for ASCII art#16
thedarkknight197 wants to merge 2 commits into
ferdinandobons:mainfrom
thedarkknight197:fix/img-art-no-char-budget

Conversation

@thedarkknight197
Copy link
Copy Markdown
Contributor

@thedarkknight197 thedarkknight197 commented May 28, 2026

Problem

When publishing a post with an image, _convert_image_to_art capped the art to the remaining character budget (max_chars - text_len - 20). For a typical post with ~100 chars of text, this left ~860 chars for the art.

With a portrait photo (e.g. 3024×4032), the max_chars constraint in image_to_ascii shrinks width iteratively until the art fits — converging to ~38 chars wide. The result is unrecognizable noise.

Fix

Remove the budget constraint entirely. ASCII art is already exempt from the post character limit (added in #13: has_image check skips the max_chars validation on text). There's no reason to cap the art separately — it lives in an HTML comment and doesn't affect readability.

Art now generates at full quality: 80 chars wide by default.

Before vs After

Before (38 chars wide — unrecognizable):

::,~-{{1t|)t\>:IIllll!!!!iiiiiiii_|{
,,^}[_)[r{\(\1;;IIIllllll!!!!!i!>[1{
""^{?_1{x}\)/fI:;;IIIIIlllllll!I~{}1
^^^1-_{1r[\1//;,::;;;IIIIIIIIII;i[}1

After (80 chars wide — Ferrari + person + Dubai skyline clearly visible):

::::::::1;if|)[]\\ft|j1{fr/)t?,IIIIIlllllll!!!!!!!!iiiiiiiiiiiiiiii>>>>>>}]?jt}(
:,:::::~[-{]}1(]{\//)\([|rt1/-,I;IIIIIllllllllllll!!!!!!!!!iiiiiiiiiiiii><l|1)}}
,,,,:,\{))?,[|/+_jrr1?|/\||1/1;:;;IIIIIIlllllllllll!!!!!!!!!!!!!!!iiiiiii,](})1[
,,,,,"\1))-;[|\+?jjr1](t/)1)xj{!:;;IIIIIIIIlllllllllllll!!!!!!!!!!!!!!i!>{)[}1([
,",,,^`)))_;}|\~-jrr1](/\)1(xj\<,;;;;IIIIIIIIIIllllllllllllllll!!!!!!!!I]1[}}{([
"""",^^(1(+;}||~}rrr1?(/\11(rj|>,::;;;;;IIIIIIIIIllllllllllllllllllllllI<}[[{}([
"^"",`"|1(~;[|(<{jjr{?(//1{(xj|>"::::;;;;;;IIIIIIIIIIIIllllllllllllllllI>}[[[[|}
"^"""\,|1(<;[\(<1jjr{?(//1{(rj|>"::::::;;;;;;IIIIIIIIIIIIIIIIIIIIIIIIIII![[[}}(}
^^^^"';\1(>;}|)>1jfj}-(/\1{(rj|>^,,::::::;;;;;;;IIIIIIIIIIIIIIIIIIIII;I;l][[}}(1
^`^^^'I\{(i;}\1>1jff[-)\|{{(jj|>^,,,,::::::::;;;;;;;IIIIIIIIIII;I::;;;;:;]}[}{((
````^'!\{(!;[f)i1jtf[-1||{}(jj|>`,,,,,,,:::::::;;;;;;;;;;;;;;;;;:!l,:,,:,-}}}}1|
`\\``'>\{(l:}j|i(f/t]-{|({{|rx|>`,,,,,,,,,:::::::::;;;;;;;;;;;;I'-[<_~-I`_{[[}1\
\\\\`'~|{(:l1j|<//\/]_{|(}}(fj|>\""",,,,,,,,::::::::::::::::::::I?1[___]~>{}}}{\
' ..'.+|}\_~)j|>\/|\]_[(([|\rr\<\^^"",,,,,,,,,,,:::::::::::::::,i?)}+++}]i{}}{{(
-<l,`I}(}/(-(r/>/\|\]_[((]//rx\<'^`\````"",,,,,,,,,::,,,,::::::,l-)}__+]}~}}}{1(
_-?]-[)(1t/[|rj+\\((?_]))]|/rx\<'`^-(/|_^"",,,,,,,,,,,,,,,,,,,:"l_1{_++?{~}[{}{1
<>>>>>>~_]1{(jct/|)(?_[(1]\tjx\<..][?\nX<`,",,,,,,,,,,,,,,,,,,,"I_1{-__-1~[[}[[]
<>>>iii!!!!i>~-}1(1(]_](([ftjx/<..;}{(jf}`"""",,,,,,,,,,,,,,,,,":~11-~~_1~[[[[[]
>i>iiiiiiii!!!llli>~__])|{rfrn\_\''l{jnc-`"",,",,,,,,,,,,,,,,,,":~{1_<<+1~?[}}}}
>i>iiiiiiiiiiiiii!!ll!i>~_{\(f/(;.`':1rt_~~;^^,,,,,,,,,,,,,,,",",~{1-~<~1_-[[]]]
>>>iiiiiiiiiiiiiiiiiii!!!l+[?-_[!,,`^]}>!>:^``;I,:,"^^""^^^^"""""~})?>i<]++?][{(
!i>iiiiiiiiii>>>>>>iiiiii!>[+~_1(\,.',~l^..:iIl;;}/(]!::i>i::^"""<]{{]-]]{/fvrjx
}~!iiiiiiiii>>>>>>i~+>>>-[{][)jxu|.`.\^\.^`I~~l`;;+\nuj)/jxx]\\`I{|(||()//{{?}~+
U[l>iiiiiiii>>><><~[1(+~)fj11((|\[\:``,"\I^`ll!I:``I[(|{1|/f{I!lI-1|1+_-}1[~iI .
->!l!!!!iiii>>~_?(/|||){()1(((|\(("`^.\...\`",l~I."+_][{11(|\)-[?~_~__;<[-\[l"Ii
])1}{{11((11111}(////\|\/////////)'^i:.`^'`:"``!>!>[|ttftttft/[>>>~ll>!li?I;i-]<
1{}[]??-__+]//)|/t/\(1((|///////t(<?~>l^>)l\,,![\x/jxrxxnnuvxrn_>~~+++______---_
iiiii>><~__{|({//\)11)(||\//////\tx\[/jxXUf~]-}|uunnxxnvvuxrjrv[>~++________++++
?][}{{1)(((|\j|)|)1)||\\\\\\\\/1(nvUUYYYYYXj/truXXnnuucunxxnvut]]]]_>i>><+++_++_
1111{{}[]?{tfrunxjjjjrrrrrrrrxjfnzYYYYYYXXYYXzxrcYvcXXXzcvunnvf/\\\|1]~I"`^,,,^\
[]---][1((|\ttxzYUYXXXYYYYXXXcxuXYYYYYXYXXXYYzjjvYYzcvvvvvvnf||v||\\\//|{_il;l>~
~_{fncYUUYctrvvvczXXczzXXXzYYzXYYYYUUUYYYYYYYcxxXYXccczzcvvnx|1zf///\\||\\|)[+lI
(|/YYYcnj/rzUYYYXzcXYYXXXXz\/jYYYYUujcYYYYYYYYcnXYYYYYYYYYzcunrcjfffft//\\1[-_<l
t///|(1111xXzYXzccczzXXXYYz-[-vYYYYt-nYYYYYYYYvxzYYYYYYYYYYYXccctftfft/\\\|({?~!
1{}}{1)(||\juzXXXXXzcczzzzXYYYXYYYYYYYYYYYYYYYvxuYYYYYYYYYYYYYYnffffffft/\\||\|(
{{1))((|\/fjncYUYYYzcvvuunnnnnuYYYYznuuuvvvvcXcxnXYYYYYYYYYYYYUcjfft/////\\|||(|
111)(((|\\tjxuczXYYYYYYYYYYYYYYYYYYYYYYYYYYYYYXnncYYYYYYYYYYYXzvxjft////\||||((1
)))((((((|\/tfjrxnxt((|/frnuvcXUYYUUYYYYYYYYYYYuxvYYYXXzzXzzccvurf//////\||((|({
))))((((((||\/tt|}-_-?][]]][{1?<]]?[]))(||\/tffxrnYzrrjrnvunrf|{]_[/\\|||((|)?++
111111))))((||1-~<<~++-----?+:..\l<+1rjjjffffftjxvYc||||(1{]-__-?])\\\\\\|([~ii>
111111))))(1[+><<<~~++++_--:\^l~{|(||((){}}[]]?]~_(1----??[{)|/ffft/|){[?-+>><>>
1111111)){?~>><~<<~~~~~+++~~-]]]-+~+~+____-?--]<..':])|tjxxnxxjt|1[-+<>>>i><>>>>
1{{{111}_>!i>>>><~~~~~+______--_-?????-____-_+_>''``lnvuxft|1[?_~~~<<<<<<<>>>>>>
1{11{]~i!iiiii>><<~~~++++_--_?????]]]???]?---__+".''`(nt(-+~~~<~~~~~<<>>>><>>><<
1{{]~!!!ii>ii>>>><<<~~+++__---???]]]]?------__++I...']n]~+~~~~~~~~~~~<<<<<<>>><~

Replace dense 70-char gradient with threshold-based sparse mapping:
- Pixels above threshold (default 140) → space (sky/background areas)
- Pixels below threshold → @%#*+=-: character set (shadows/edges only)
- Result: airy asciiart.eu style where whitespace creates the image
Art is embedded in an HTML comment and explicitly exempt from the
post character limit. Capping it to the remaining text budget
forced portrait images down to ~38 chars wide, producing unreadable
output. Remove the budget constraint so img2ascii runs at full
quality (80 chars wide by default).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant