Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c775d3e

Browse files
Update photo_to_ascii.py
1 parent 4109ed0 commit c775d3e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

‎Photo To Ascii/photo_to_ascii.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,17 @@ def photoascii():
2222
except Exception:
2323
print("Invalid path")
2424
return
25-
25+
#Fetching the name of the image
26+
image_name=""
27+
flag=0
28+
for i in path[::-1]:
29+
if i=="/":
30+
break
31+
if flag==1:
32+
image_name=i+image_name
33+
if i=='.':
34+
flag=1
35+
2636
#Resizing of image
2737
new_width=100
2838
width, height = image.size
@@ -38,7 +48,7 @@ def photoascii():
3848

3949

4050
# save result to "ascii_image.txt"
41-
with open("./Photo To Ascii/ascii_image.txt", "w") as f:
51+
with open("./Photo To Ascii/{}(ASCII).txt".format(image_name), "w") as f:
4252
f.write(ascii_image)
4353
# run program
4454
if __name__=='__main__':

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /