Skip to content

Commit

Permalink
Merge pull request #2 from phy1729/main
Browse files Browse the repository at this point in the history
Use ImageOps.scale to fit image to width
  • Loading branch information
xfnw authored Jun 18, 2021
2 parents e67aa49 + 25ad3f6 commit 40727c6
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions banter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,24 @@
# unbuffered mode lol

import sys,time,argparse
from PIL import Image
from PIL import Image, ImageOps
from color import closestColor


def main(imgPath,delay,ASCIIWIDTH,COLORCHAR,FILLER):
im = Image.open(imgPath, 'r')
im = ImageOps.scale(im, ASCIIWIDTH / im.width)
width, height = im.size
pixel_values = list(im.getdata())

ipix = width // ASCIIWIDTH # // instead of / to devide with a round number

asciiHeight = height // ipix // 2

currentPixel = 0

for y in range(asciiHeight):
for y in range(0, height, 2):
line = []
lastColor=69420

for x in range(ASCIIWIDTH):
color = closestColor(pixel_values[width*(y*(ipix*2))+(x*ipix)])
for x in range(width):
color = closestColor(pixel_values[width*y+x])
if color == lastColor:
colorcode = ''
else:
Expand Down

0 comments on commit 40727c6

Please sign in to comment.