User:Jacopo/Prototyping: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
 
(48 intermediate revisions by the same user not shown)
Line 3: Line 3:
<span style="color:black ;font-size:30px ;"> ↪Prototyping </span>
<span style="color:black ;font-size:30px ;"> ↪Prototyping </span>
</div> <br><br>
</div> <br><br>
''The Analytical Engine has no pretentions whatever to '''originate''' anything. It can do whatever '''we know how to order''' it to perform.'' – Ada Lovelace (1843)


[[File:im.all.ears.png|200px|right]]
=First Trimester=
 
== Let's start ==
=Notes=
 
== '''Tue 15.09''' Lesson w/ Aymeric, Michael, Manetta ==
 
== '''Mon 21.09''' Lesson 2 w/ Michael ==
 
=='''Mon 28.09''' Lesson 3 w/ Manetta ==
 
=='''Wed 30.09''' Lesson 4 w/ Michael ==
PAD: https://pad.xpub.nl/p/2020-09-30-prototyping


'''Morning Journey inside some individual experiments.''' <br>
'''Morning Journey inside some individual experiments.''' <br>
Line 43: Line 34:
</syntaxhighlight> <br>
</syntaxhighlight> <br>


> Differences between LOOP and WHILE
> Differences between LOOP and WHILE <br>
> Differences between FLAT LOOP and NESTING LOOP
[[File:punchedcard.png|600px|right]]
 
==PIL==
The Python Imaging Library (PIL) adds image processing capabilities to your Python interpreter.
This library provides extensive file format support, an efficient internal representation, and fairly powerful image processing capabilities. It should provide a solid foundation for a general image processing tool.
 
Blending two images:
[[File:Blendprocess.png]]
<syntaxhighlight lang="python">
Image.blend(use1.convert("RGBA"), use2.convert("RGBA"), 0.5)
#The two images must have the same mode and size
</syntaxhighlight>
 
NOTEBOOK of the day: https://git.xpub.nl/XPUB/S13-Words-for-the-Future-notebooks <br>
PAD of the day: https://pad.xpub.nl/p/2020-09-30-prototyping <br>
==NLTK==
 
<syntaxhighlight lang="python">
import nltk
import random
 
lines = open('./language.txt').readlines()
sentence = random.choice(lines)
print(sentence)
Neocapitalism has also discovered some advantages in large scale. Day and night it talks of nothing but city planning and national development. But its real concern is obviously the conditioning of commodity production, which it senses escaping it unless it resorts to this new scale. Academic urbanism has accordingly defined “slums” from the standpoint of postwar neocapitalism. Its techniques of urban renewal are based on sterile, antisituationist criteria.
</syntaxhighlight>
 
<syntaxhighlight lang="python">
tokens = nltk.word_tokenize(sentence)
print(tokens)
['Neocapitalism', 'has', 'also', 'discovered', 'some', 'advantages', 'in', 'large', 'scale', '.', 'Day', 'and', 'night', 'it', 'talks', 'of', 'nothing', 'but', 'city', 'planning', 'and', 'national', 'development', '.', 'But', 'its', 'real', 'concern', 'is', 'obviously', 'the', 'conditioning', 'of', 'commodity', 'production', ',', 'which', 'it', 'senses', 'escaping', 'it', 'unless', 'it', 'resorts', 'to', 'this', 'new', 'scale', '.', 'Academic', 'urbanism', 'has', 'accordingly', 'defined', '“', 'slums', '”', 'from', 'the', 'standpoint', 'of', 'postwar', 'neocapitalism', '.', 'Its', 'techniques', 'of', 'urban', 'renewal', 'are', 'based', 'on', 'sterile', ',', 'antisituationist', 'criteria', '.']
</syntaxhighlight>
It's important to realize that POS tagging is not a fixed property of a word -- but depends on the context of each word. The NLTK book gives an example of homonyms -- words that are written the same, but are actually pronounced differently and have different meanings depending on their use.
<syntaxhighlight lang="python">
 
text = nltk.word_tokenize("They refuse to permit us to obtain the refuse permit")
nltk.pos_tag(text)
[('They', 'PRP'),
('refuse', 'VBP'),
('to', 'TO'),
('permit', 'VB'),
('us', 'PRP'),
('to', 'TO'),
('obtain', 'VB'),
('the', 'DT'),
('refuse', 'NN'),
('permit', 'NN')]
</syntaxhighlight>
 
== ASCII Canvas ==
<syntaxhighlight lang="python">
width = 10
height = 10
 
# Simple fill-up of a page, to set the reach of our canvas
lines = [] # All the lines will be stored here
 
for linenumber in range(height):
    line = '▄︻┻═━一' * width
    lines.append(line)
 
print('\n'.join(lines))
▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一
▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一
▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一
▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一
▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一
▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一
▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一
▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一
▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一
▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一▄︻┻═━一
</syntaxhighlight>
 
 
<syntaxhighlight lang="python">
 
 
width = 20
height = 20
line = ''
 
for y in range(height):
   
    # here i collect all the characters for one line
    for x in range(width):
       
        # check if the line "number" is odd or even
        # to do this, you can use the "%", called the "modulo"
        if y % 2 == 0:
            line += '♫♫♫'
            line += '  '
        else:
            line += '  '
            line += '♪♪♪'
           
    # print & reset
    print(line)
    line = ''
♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫ 
  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪
♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫ 
  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪
♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫ 
  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪
♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫ 
  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪
♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫ 
  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪
♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫ 
  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪
♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫ 
  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪
♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫ 
  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪
♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫ 
  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪
♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫  ♫♫♫ 
  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪  ♪♪♪
</syntaxhighlight>
 
<syntaxhighlight lang="python">
 
# Another way to fill-up the page
import random
 
lines = []
 
txt = open('./language.txt', 'r').read()
words = txt.split()
 
for linenumber in range(height):
    word = random.choice(words)
    length_of_word = len(word)
    nr_of_words_fit_in_line = width / length_of_word
    line = word * int(nr_of_words_fit_in_line)
    lines.append(line)
   
print('\n'.join(lines))
postwarpostwarpostwarpostwarpostwarpostwarpostwarpostwarpostwarpostwar
ititititititititititititititititititititititititititititititititititititit
scale.scale.scale.scale.scale.scale.scale.scale.scale.scale.scale.scale.
“slums”“slums”“slums”“slums”“slums”“slums”“slums”“slums”“slums”“slums”
ButButButButButButButButButButButButButButButButButButButButButButButButBut
sterile,sterile,sterile,sterile,sterile,sterile,sterile,sterile,sterile,
criteria.criteria.criteria.criteria.criteria.criteria.criteria.criteria.
unlessunlessunlessunlessunlessunlessunlessunlessunlessunlessunlessunless
isisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisis
ititititititititititititititititititititititititititititititititititititit
ButButButButButButButButButButButButButButButButButButButButButButButButBut
nationalnationalnationalnationalnationalnationalnationalnationalnational
postwarpostwarpostwarpostwarpostwarpostwarpostwarpostwarpostwarpostwar
DayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDay
ititititititititititititititititititititititititititititititititititititit
ofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofof
ofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofof
ononononononononononononononononononononononononononononononononononononon
isisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisis
ititititititititititititititititititititititititititititititititititititit
whichwhichwhichwhichwhichwhichwhichwhichwhichwhichwhichwhichwhichwhichwhich
neocapitalism.neocapitalism.neocapitalism.neocapitalism.neocapitalism.
basedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbased
antisituationistantisituationistantisituationistantisituationist
commoditycommoditycommoditycommoditycommoditycommoditycommoditycommodity
ititititititititititititititititititititititititititititititititititititit
newnewnewnewnewnewnewnewnewnewnewnewnewnewnewnewnewnewnewnewnewnewnewnewnew
butbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbut
advantagesadvantagesadvantagesadvantagesadvantagesadvantagesadvantages
neocapitalism.neocapitalism.neocapitalism.neocapitalism.neocapitalism.
defineddefineddefineddefineddefineddefineddefineddefineddefineddefined
ititititititititititititititititititititititititititititititititititititit
tototototototototototototototototototototototototototototototototototototo
concernconcernconcernconcernconcernconcernconcernconcernconcernconcern
basedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbased
ititititititititititititititititititititititititititititititititititititit
standpointstandpointstandpointstandpointstandpointstandpointstandpoint
“slums”“slums”“slums”“slums”“slums”“slums”“slums”“slums”“slums”“slums”
ofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofof
criteria.criteria.criteria.criteria.criteria.criteria.criteria.criteria.
ititititititititititititititititititititititititititititititititititititit
resortsresortsresortsresortsresortsresortsresortsresortsresortsresorts
production,production,production,production,production,production,
conditioningconditioningconditioningconditioningconditioningconditioning
discovereddiscovereddiscovereddiscovereddiscovereddiscovereddiscovered
basedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbased
sterile,sterile,sterile,sterile,sterile,sterile,sterile,sterile,sterile,
basedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbased
ininininininininininininininininininininininininininininininininininininin
postwarpostwarpostwarpostwarpostwarpostwarpostwarpostwarpostwarpostwar
“slums”“slums”“slums”“slums”“slums”“slums”“slums”“slums”“slums”“slums”
butbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbut
ititititititititititititititititititititititititititititititititititititit
ofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofof
thisthisthisthisthisthisthisthisthisthisthisthisthisthisthisthisthisthis
nightnightnightnightnightnightnightnightnightnightnightnightnightnightnight
planningplanningplanningplanningplanningplanningplanningplanningplanning
sensessensessensessensessensessensessensessensessensessensessensessenses
nationalnationalnationalnationalnationalnationalnationalnationalnational
commoditycommoditycommoditycommoditycommoditycommoditycommoditycommodity
scale.scale.scale.scale.scale.scale.scale.scale.scale.scale.scale.scale.
thisthisthisthisthisthisthisthisthisthisthisthisthisthisthisthisthisthis
planningplanningplanningplanningplanningplanningplanningplanningplanning
defineddefineddefineddefineddefineddefineddefineddefineddefineddefined
isisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisis
</syntaxhighlight>
 
Exporting with ReportLab – https://www.reportlab.com/
<syntaxhighlight lang="python">
from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import mm
 
pagewidth = 210*mm
pageheight = 297*mm
 
c = Canvas("ASCII-canvas-to-PDF.new.pdf", pagesize=(pagewidth, pageheight), bottomup=0)
c.setFont('Courier', 12)
 
start_y = 10*mm # start position of the lines
 
y = start_y
lineheight = 4*mm
 
if multipage == True:
    for page in pages:
        for line in page:
            c.drawCentredString(pagewidth/2, y, line)
            y += lineheight
        c.showPage()
        y = start_y
else:
    for line in lines:
        c.drawCentredString(pagewidth/2, y, line)
        y += lineheight
   
c.save()
</syntaxhighlight>
 
== Making an ASCII art PDF using aalib, PIL, and reportlab ==
<syntaxhighlight lang="python">
from PIL import Image
from urllib.request import urlopen
import aalib
 
#f = urlopen("Pongie.Undisciplined.Map.jpg")
im = Image.open("Pongie.Undisciplined.Map.jpg")
screen = aalib.AsciiScreen(width=200, height=160)
resized = im.convert("L").resize(screen.virtual_size)
screen.put_image((0, 0), resized)
lines = screen.render().splitlines()
 
from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.pagesizes import *
from reportlab.lib.units import mm
from reportlab.pdfbase.ttfonts import TTFont, pdfmetrics
 
c = Canvas("setyourname.pdf", pagesize=A2, bottomup=0)
fontpath = "mplus-1m-regular.ttf"
font =  TTFont('1mregular', fontpath)
pdfmetrics.registerFont(font)
c.setFont('1mregular', 14.4)
 
start_y = 0*mm
y = start_y
lineheight = 4*mm
 
for line in lines:
    c.drawString(2*mm, y, line)
    y += lineheight
 
c.save()
 
</syntaxhighlight>
 
== Quilting ==
 
'''Today's Goal: Making a A0 Quilt using different patches from XPUB1 Student.''' <br>
We refer to Patch both as digital and physical part of the Quilt. In the early computer era, the Patch was a set of changes for a computer programme. To update, fix or improve the programme, new paper tape or punched cards were replacing the wrong segment, after being literally cut off.
[[File:Early.patch.programme.jpg|200px|thumb|right|Physical patches used to correct punched holes by covering them. (1944)]]
 
PAD of the day: https://pad.xpub.nl/p/XPUB1_ONLINE_07_10_2020 <br>
 
'''Editing an image with: aalibb library''' <br>
> http://aa-project.sourceforge.net/aalib/ <br>
<syntaxhighlight lang="python">
#Patch 2
from PIL import Image
from urllib.request import urlopen
 
f = Image.open (urlopen("https://here's the link"))
g = f.convert("1") #for b&w
g.save ("bw.png") #to save a new copy
 
import aalib
screen = aalib.AsciiScreen(width=82, height=74) #size of the canvas
h = f.resize(screen.virtual_size).convert('L',dither=Image.NONE)
screen.put_image((0, 0), h)
print (screen.render())
</syntaxhighlight>
 
<syntaxhighlight lang="python">
from PIL import Image
from urllib.request import urlopen
 
f = Image.open (urlopen("https://2xawx0gmudy471po527lbxcd-wpengine.netdna-ssl.com/wp-content/uploads/2016/02/shutterstock_376367317-604x400.jpg"))
 
import aalib
screen = aalib.AsciiScreen(width=82, height=40) #size of the canvas
h = f.resize(screen.virtual_size).convert('L',dither=Image.NONE)
screen.put_image((0, 0), h)
print (screen.render())
 
WWBWBk6.)?!\WWBWWBWWBWWBWWBWWmr"'<ZwmWWBWWBWWBWWd()zS3XBWWBWW#???L]WWWBWWBWdf+2a2q
WmBBBWmWaa.4mBmWmBmBBmBBBmWmmmWQwmBmBBmWmBBmBBm#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mWmWmWmW
 
</syntaxhighlight>
 
== Links ==
Check-in:<br>
> https://www.effbot.org/imagingbook/pil-index.htm<br>
> https://pillow.readthedocs.io/en/stable/<br>
 
Library Sources to work with Images and ASCII: <br>
> http://aa-project.sourceforge.net/aalib/ <br>
> http://jwilk.net/software/python-aalib

Latest revision as of 08:59, 12 April 2021

↪Prototyping



The Analytical Engine has no pretentions whatever to originate anything. It can do whatever we know how to order it to perform. – Ada Lovelace (1843)

First Trimester

Let's start

Morning Journey inside some individual experiments.
> Il Pleut Bot (from Federico)

import random

width = 10
height = 10
drops = [',','    ','    ','     ']
rain = ''

for x in range(width):
    for y in range(height):
        rain += random.choice(drops)
    print(rain)
    rain = ''

> Responsive Form (from Louisa)

print('Enter your name:')
name = input()
print('Hello, ' + name + ". Are you ready to choose your own adventure? If yes, Type one of these words to kickstart the engine: hot, yellow, bright")<br>

> Differences between LOOP and WHILE
> Differences between FLAT LOOP and NESTING LOOP

Punchedcard.png

PIL

The Python Imaging Library (PIL) adds image processing capabilities to your Python interpreter. This library provides extensive file format support, an efficient internal representation, and fairly powerful image processing capabilities. It should provide a solid foundation for a general image processing tool.

Blending two images: Blendprocess.png

Image.blend(use1.convert("RGBA"), use2.convert("RGBA"), 0.5)
#The two images must have the same mode and size

NOTEBOOK of the day: https://git.xpub.nl/XPUB/S13-Words-for-the-Future-notebooks
PAD of the day: https://pad.xpub.nl/p/2020-09-30-prototyping

NLTK

import nltk
import random

lines = open('./language.txt').readlines()
sentence = random.choice(lines)
print(sentence)
Neocapitalism has also discovered some advantages in large scale. Day and night it talks of nothing but city planning and national development. But its real concern is obviously the conditioning of commodity production, which it senses escaping it unless it resorts to this new scale. Academic urbanism has accordingly defined slums from the standpoint of postwar neocapitalism. Its techniques of urban renewal are based on sterile, antisituationist criteria.
tokens = nltk.word_tokenize(sentence)
print(tokens)
['Neocapitalism', 'has', 'also', 'discovered', 'some', 'advantages', 'in', 'large', 'scale', '.', 'Day', 'and', 'night', 'it', 'talks', 'of', 'nothing', 'but', 'city', 'planning', 'and', 'national', 'development', '.', 'But', 'its', 'real', 'concern', 'is', 'obviously', 'the', 'conditioning', 'of', 'commodity', 'production', ',', 'which', 'it', 'senses', 'escaping', 'it', 'unless', 'it', 'resorts', 'to', 'this', 'new', 'scale', '.', 'Academic', 'urbanism', 'has', 'accordingly', 'defined', '“', 'slums', '”', 'from', 'the', 'standpoint', 'of', 'postwar', 'neocapitalism', '.', 'Its', 'techniques', 'of', 'urban', 'renewal', 'are', 'based', 'on', 'sterile', ',', 'antisituationist', 'criteria', '.']

It's important to realize that POS tagging is not a fixed property of a word -- but depends on the context of each word. The NLTK book gives an example of homonyms -- words that are written the same, but are actually pronounced differently and have different meanings depending on their use.

text = nltk.word_tokenize("They refuse to permit us to obtain the refuse permit")
nltk.pos_tag(text)
[('They', 'PRP'),
 ('refuse', 'VBP'),
 ('to', 'TO'),
 ('permit', 'VB'),
 ('us', 'PRP'),
 ('to', 'TO'),
 ('obtain', 'VB'),
 ('the', 'DT'),
 ('refuse', 'NN'),
 ('permit', 'NN')]

ASCII Canvas

width = 10
height = 10

# Simple fill-up of a page, to set the reach of our canvas
lines = [] # All the lines will be stored here

for linenumber in range(height):
    line = '▄︻┻═━一' * width
    lines.append(line)

print('\n'.join(lines))
▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━
▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━
▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━
▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━
▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━
▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━
▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━
▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━
▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━
▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━▄︻┻═━


width = 20
height = 20
line = ''

for y in range(height):
    
    # here i collect all the characters for one line
    for x in range(width):
        
        # check if the line "number" is odd or even
        # to do this, you can use the "%", called the "modulo"
        if y % 2 == 0:
            line += '♫♫♫'
            line += '   '
        else:
            line += '   '
            line += '♪♪♪'
            
    # print & reset
    print(line)
    line = ''
♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   
   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪
♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   
   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪
♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   
   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪
♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   
   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪
♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   
   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪
♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   
   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪
♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   
   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪
♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   
   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪
♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   
   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪
♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   ♫♫♫   
   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪   ♪♪♪
# Another way to fill-up the page
import random 

lines = []

txt = open('./language.txt', 'r').read()
words = txt.split()

for linenumber in range(height):
    word = random.choice(words)
    length_of_word = len(word)
    nr_of_words_fit_in_line = width / length_of_word
    line = word * int(nr_of_words_fit_in_line)
    lines.append(line)
    
print('\n'.join(lines))
postwarpostwarpostwarpostwarpostwarpostwarpostwarpostwarpostwarpostwar
ititititititititititititititititititititititititititititititititititititit
scale.scale.scale.scale.scale.scale.scale.scale.scale.scale.scale.scale.
slums”“slums”“slums”“slums”“slums”“slums”“slums”“slums”“slums”“slums
ButButButButButButButButButButButButButButButButButButButButButButButButBut
sterile,sterile,sterile,sterile,sterile,sterile,sterile,sterile,sterile,
criteria.criteria.criteria.criteria.criteria.criteria.criteria.criteria.
unlessunlessunlessunlessunlessunlessunlessunlessunlessunlessunlessunless
isisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisis
ititititititititititititititititititititititititititititititititititititit
ButButButButButButButButButButButButButButButButButButButButButButButButBut
nationalnationalnationalnationalnationalnationalnationalnationalnational
postwarpostwarpostwarpostwarpostwarpostwarpostwarpostwarpostwarpostwar
DayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDayDay
ititititititititititititititititititititititititititititititititititititit
ofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofof
ofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofof
ononononononononononononononononononononononononononononononononononononon
isisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisis
ititititititititititititititititititititititititititititititititititititit
whichwhichwhichwhichwhichwhichwhichwhichwhichwhichwhichwhichwhichwhichwhich
neocapitalism.neocapitalism.neocapitalism.neocapitalism.neocapitalism.
basedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbased
antisituationistantisituationistantisituationistantisituationist
commoditycommoditycommoditycommoditycommoditycommoditycommoditycommodity
ititititititititititititititititititititititititititititititititititititit
newnewnewnewnewnewnewnewnewnewnewnewnewnewnewnewnewnewnewnewnewnewnewnewnew
butbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbut
advantagesadvantagesadvantagesadvantagesadvantagesadvantagesadvantages
neocapitalism.neocapitalism.neocapitalism.neocapitalism.neocapitalism.
defineddefineddefineddefineddefineddefineddefineddefineddefineddefined
ititititititititititititititititititititititititititititititititititititit
tototototototototototototototototototototototototototototototototototototo
concernconcernconcernconcernconcernconcernconcernconcernconcernconcern
basedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbased
ititititititititititititititititititititititititititititititititititititit
standpointstandpointstandpointstandpointstandpointstandpointstandpoint
slums”“slums”“slums”“slums”“slums”“slums”“slums”“slums”“slums”“slums
ofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofof
criteria.criteria.criteria.criteria.criteria.criteria.criteria.criteria.
ititititititititititititititititititititititititititititititititititititit
resortsresortsresortsresortsresortsresortsresortsresortsresortsresorts
production,production,production,production,production,production,
conditioningconditioningconditioningconditioningconditioningconditioning
discovereddiscovereddiscovereddiscovereddiscovereddiscovereddiscovered
basedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbased
sterile,sterile,sterile,sterile,sterile,sterile,sterile,sterile,sterile,
basedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbasedbased
ininininininininininininininininininininininininininininininininininininin
postwarpostwarpostwarpostwarpostwarpostwarpostwarpostwarpostwarpostwar
slums”“slums”“slums”“slums”“slums”“slums”“slums”“slums”“slums”“slums
butbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbutbut
ititititititititititititititititititititititititititititititititititititit
ofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofofof
thisthisthisthisthisthisthisthisthisthisthisthisthisthisthisthisthisthis
nightnightnightnightnightnightnightnightnightnightnightnightnightnightnight
planningplanningplanningplanningplanningplanningplanningplanningplanning
sensessensessensessensessensessensessensessensessensessensessensessenses
nationalnationalnationalnationalnationalnationalnationalnationalnational
commoditycommoditycommoditycommoditycommoditycommoditycommoditycommodity
scale.scale.scale.scale.scale.scale.scale.scale.scale.scale.scale.scale.
thisthisthisthisthisthisthisthisthisthisthisthisthisthisthisthisthisthis
planningplanningplanningplanningplanningplanningplanningplanningplanning
defineddefineddefineddefineddefineddefineddefineddefineddefineddefined
isisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisisis

Exporting with ReportLab – https://www.reportlab.com/

from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import mm

pagewidth = 210*mm
pageheight = 297*mm

c = Canvas("ASCII-canvas-to-PDF.new.pdf", pagesize=(pagewidth, pageheight), bottomup=0)
c.setFont('Courier', 12)

start_y = 10*mm # start position of the lines

y = start_y
lineheight = 4*mm

if multipage == True:
    for page in pages:
        for line in page:
            c.drawCentredString(pagewidth/2, y, line)
            y += lineheight
        c.showPage()
        y = start_y
else:
    for line in lines:
        c.drawCentredString(pagewidth/2, y, line)
        y += lineheight
    
c.save()

Making an ASCII art PDF using aalib, PIL, and reportlab

from PIL import Image
from urllib.request import urlopen
import aalib

#f = urlopen("Pongie.Undisciplined.Map.jpg")
im = Image.open("Pongie.Undisciplined.Map.jpg")
screen = aalib.AsciiScreen(width=200, height=160)
resized = im.convert("L").resize(screen.virtual_size)
screen.put_image((0, 0), resized)
lines = screen.render().splitlines()

from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.pagesizes import *
from reportlab.lib.units import mm
from reportlab.pdfbase.ttfonts import TTFont, pdfmetrics

c = Canvas("setyourname.pdf", pagesize=A2, bottomup=0) 
fontpath = "mplus-1m-regular.ttf"
font =  TTFont('1mregular', fontpath)
pdfmetrics.registerFont(font)
c.setFont('1mregular', 14.4)

start_y = 0*mm
y = start_y
lineheight = 4*mm

for line in lines:
    c.drawString(2*mm, y, line)
    y += lineheight

c.save()

Quilting

Today's Goal: Making a A0 Quilt using different patches from XPUB1 Student.
We refer to Patch both as digital and physical part of the Quilt. In the early computer era, the Patch was a set of changes for a computer programme. To update, fix or improve the programme, new paper tape or punched cards were replacing the wrong segment, after being literally cut off.

Physical patches used to correct punched holes by covering them. (1944)

PAD of the day: https://pad.xpub.nl/p/XPUB1_ONLINE_07_10_2020

Editing an image with: aalibb library
> http://aa-project.sourceforge.net/aalib/

#Patch 2
from PIL import Image
from urllib.request import urlopen

f = Image.open (urlopen("https://here's the link"))
g = f.convert("1") #for b&w
g.save ("bw.png") #to save a new copy 

import aalib
screen = aalib.AsciiScreen(width=82, height=74) #size of the canvas
h = f.resize(screen.virtual_size).convert('L',dither=Image.NONE)
screen.put_image((0, 0), h)
print (screen.render())
from PIL import Image
from urllib.request import urlopen

f = Image.open (urlopen("https://2xawx0gmudy471po527lbxcd-wpengine.netdna-ssl.com/wp-content/uploads/2016/02/shutterstock_376367317-604x400.jpg"))

import aalib
screen = aalib.AsciiScreen(width=82, height=40) #size of the canvas
h = f.resize(screen.virtual_size).convert('L',dither=Image.NONE)
screen.put_image((0, 0), h)
print (screen.render())


WWBWBk6.)?!\WWBWWBWWBWWBWWBWWmr"'<ZwmWWBWWBWWBWWd()zS3XBWWBWW#???L]WWWBWWBWdf+2a2q
WmBBBWmWaa.4mBmWmBmBBmBBBmWmmmWQwmBmBBmWmBBmBBm#m[+oJSqmm4Wm'a'+WaWmWmBBmW#o3a-"4J
WmWmW#???J\]WTmmSmd#DmWmWBBBWBBmmWmWF"??gZBWBWBQnV/""{jWWwYwdadQBmmWmBB#WmW12c.]WW
WmPBB\]])jQWf!.-?ZZ##UdDmWmWmWmWBBBLmmm/)mW#BmBm12(.]WWmmmBBWBWWmWP?[/\y6]BkoX )BB
WmmaamgmBWBP=Jmma"  !!##hZBBBBBBBBWBmX3m,j#ZWBWBZSn ]WmWWBWmBBBm[u'^\ajWmWmW12; 4W
WmWmmBBBBBB[#haA#[aac  !4#m#BWmWmg]mXqm#[J##mmBBmvS, $mWmBmWBWmWL"$W$WWWmWmWm2X, $
4W9XU#WmWmWmD####ummmWa, "Z#ZmWmWZ]mWZ!{/.]#hBWmBEno.-WmWmWmWmWm?,<.)w4WmWmBmz2a -
_`o2123BBWmWmmgmmBWBWmWBa.J<mZWm()$mWmWWW/ $#dWmWm22s "VmZVU4BBLi|i);j|)WmWBWm22o,
3 X}moSmWmWmWBBmWmWmBBBBP<as )dW_mJWmWmmB6.]#ZmWmWmp2s .=XnnX$Bk|)k|;]+|)$mBBBWuS2
d:4n2S^WmWmWmBWP#"?#$BWm3#FX#,<D;<mWm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i|<w??\WmBWmWB
W9as/'j\P4mWBBmWmWmWm[ )o$mPa,.4mzd#LWmWmBBBPdmY#m4BBWmWmWBBBW#Y+||>~-7__=<-$mWmBB
6#2Sm;]6]%4WmWBBBBBBB[ )odWBa4w ?#Z?jmWmWmWBFmLJW#+mWPsWmWmWmY=||" . __|s=c)]WmWmW
]#<h#(]WL)\WmWmWmWmWmf.)ommL-]h6asa)  ??????\!##!'w#B[WmWmWZ(|>` _aBWWz||T(|jWmWmW
2###7.ZWWLa%$mWmWmWmW[ o2dWZo(mWwvm#6as.    _ac_aJwmWmJ4mWZ<w< _jWBBBmmawawdWBWmWm
Wa}.wJdBBWBW]BBBBBP?Y-.S2dWma_QmWm6BX#U##mmmBmq#3mWBWZ) WD7(  'WmWmWmWWmmBmWmWmWmW

Links

Check-in:
> https://www.effbot.org/imagingbook/pil-index.htm
> https://pillow.readthedocs.io/en/stable/

Library Sources to work with Images and ASCII:
> http://aa-project.sourceforge.net/aalib/
> http://jwilk.net/software/python-aalib