memex-in commited on
Commit
9cdc5ef
·
verified ·
1 Parent(s): 0891f86

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -2,7 +2,7 @@ import os
2
  import streamlit as st
3
  from selenium import webdriver
4
  from selenium.webdriver.chrome.options import Options
5
- import ascii_magic
6
 
7
  # Function to capture a screenshot of a webpage
8
  def capture_screenshot(url, output_path='screenshot.png'):
@@ -23,7 +23,7 @@ def capture_screenshot(url, output_path='screenshot.png'):
23
  def convert_to_ascii(image_path):
24
  try:
25
  # Correct usage of ascii_magic to convert image to ASCII
26
- ascii_art = ascii_magic.to_ascii_image(image_path, columns=100, mode='mono')
27
  return ascii_art
28
  except Exception as e:
29
  raise Exception(f"Failed to convert image to ASCII: {e}")
@@ -42,7 +42,7 @@ if st.button("Generate ASCII Screenshot"):
42
  capture_screenshot(url, screenshot_file)
43
 
44
  st.write("Converting to ASCII art...")
45
- ascii_output = convert_to_ascii(screenshot_file)
46
 
47
  # Display ASCII art in a text area
48
  st.text_area("ASCII Art Output", ascii_output, height=600)
 
2
  import streamlit as st
3
  from selenium import webdriver
4
  from selenium.webdriver.chrome.options import Options
5
+ from ascii_magic import AsciiArt
6
 
7
  # Function to capture a screenshot of a webpage
8
  def capture_screenshot(url, output_path='screenshot.png'):
 
23
  def convert_to_ascii(image_path):
24
  try:
25
  # Correct usage of ascii_magic to convert image to ASCII
26
+ ascii_art = AsciiArt.from_image(image_path, columns=100, mode='mono')
27
  return ascii_art
28
  except Exception as e:
29
  raise Exception(f"Failed to convert image to ASCII: {e}")
 
42
  capture_screenshot(url, screenshot_file)
43
 
44
  st.write("Converting to ASCII art...")
45
+ ascii_output = AsciiArt.from_image(screenshot_file)
46
 
47
  # Display ASCII art in a text area
48
  st.text_area("ASCII Art Output", ascii_output, height=600)