Skip to content

Commit 93bf57c

Browse files
authored
Merge pull request #357 from geeseven/args-chars
add option to change character set
2 parents dd2c43b + 1a5c53e commit 93bf57c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Diff for: tools/image_to_ascii.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env python3
22

3-
# Original script by @atluft with inspiration from http://link.medium.com/0D6TnUKTIab located at:
3+
# Original script by @atluft with inspiration from http://link.medium.com/0D6TnUKTIab located at: # noqa: E501
44
# https://github.com/o2sh/onefetch/wiki/ASCII-Art-From-Image-Using-Python-Image-Library/9c454b390273ffedd60db9d525fb001f89d581b1
55

66
# lint with
7-
# flake8 --max-line-length 120 image_to_ascii.py
7+
# flake8 --max-line-length 88 image_to_ascii.py
88
# black --color --diff image_to_ascii.py
99
# isort --color --diff image_to_ascii.py
1010

@@ -17,6 +17,12 @@
1717

1818
parser = ArgumentParser(description="convert an image file to ASCII art")
1919
requiredNamed = parser.add_argument_group("required argument")
20+
requiredNamed.add_argument(
21+
"-c",
22+
"--characters",
23+
help='characters available to be used, default " .:_-"',
24+
default=" .:_-",
25+
)
2026
requiredNamed.add_argument(
2127
"-f",
2228
"--file",
@@ -61,8 +67,7 @@
6167

6268

6369
def getSomeChar(h):
64-
chars = "-_:. "[::-1]
65-
charArr = list(chars)
70+
charArr = list(args.characters)
6671
mul = len(charArr) / 256
6772
return charArr[floor(h * mul)]
6873

0 commit comments

Comments
 (0)