async def customization_ascii(call: CallbackQuery): await call.answer(cache_time=3) username = call.from_user.username await call.message.edit_text('Wait some seconds...') # Customization for default ascii output = ascii_magic.from_image_file(f'docs/{username}/picture.png', columns=129, mode=ascii_magic.Modes.ASCII) with open(f'docs/{username}/ascii.txt', "w") as f: f.write(output) # txt to to png imgkit.from_file(f'docs/{username}/ascii.txt', f'docs/{username}/ascii.png') await call.message.edit_text('Done! Sending ...') size_b = os.path.getsize(f'docs/{username}/ascii.png') # Size of screenshot in bytes size_mb = size_b / 1_000_000 # Size of screenshot in mb if size_mb < 10: # restriction of Telegram. Image can't be more than 10mb await call.message.answer_photo(InputFile(path_or_bytesio=f'docs/{username}/ascii.png')) await call.message.answer_document(InputFile(f'docs/{username}/ascii.png')) await call.message.answer_document(InputFile(f'docs/{username}/ascii.txt')) else: await call.message.answer('So big size of photo. Sending only photo-file...') await call.message.answer_document(InputFile(f'docs/{username}/ascii.png')) await call.message.answer_document(InputFile(f'docs/{username}/ascii.txt')) await call.message.delete() shutil.rmtree(f'docs/{username}/') # Removing dir with user files
async def default_html(call: CallbackQuery): """Converting image to html, and taking screenshot of html page""" await call.answer(cache_time=3) username = call.from_user.username await call.message.edit_text('Wait some seconds...') output = ascii_magic.from_image_file( f'docs/{username}/picture.png', columns=1000, mode=ascii_magic.Modes.HTML) # Customization for default html doc ascii_magic.to_html_file(f'docs/{username}/ascii.html', output) # Reversing from image to html imgkit.from_file(f'docs/{username}/ascii.html', f'docs/{username}/html.png') # Screenshot from html page ########################################################################################### # Cropping Image # image = Image.open(f'docs/{username}/html.png') width, height = image.size # Cropping coordinates left = 8 top = 16 right = width bottom = height - top # Cropped image of above dimension im = image.crop((left, top, right, bottom)) # Shows the image in image viewer im.save(f'docs/{username}/html.png') ########################################################################################### size_b = os.path.getsize( f'docs/{username}/html.png') # Size of screenshot in bytes size_mb = size_b / 1_000_000 # Size of screenshot in mb await call.message.edit_text('Done! Sending ...') if size_mb < 10: # restriction of Telegram. Image can't be more than 10mb await call.message.answer_photo( InputFile(path_or_bytesio=f'docs/{username}/html.png')) await call.message.answer_document( InputFile(f'docs/{username}/html.png')) await call.message.answer_document( InputFile(f'docs/{username}/ascii.html')) else: await call.message.answer( 'So big size of photo. Sending only photo-document...') await call.message.answer_document( InputFile(f'docs/{username}/html.png')) await call.message.answer_document( InputFile(f'docs/{username}/ascii.html')) await call.message.delete() shutil.rmtree(f'docs/{username}/') # Removing dir with user files7
def about_us(): """Prints an about us section""" if console.console.width > 200: gst_logo = ascii_magic.from_image_file( "images/gst_logo_lockup_rGreen_with_letters.png", columns=console.console.width, width_ratio=2, ) elif console.console.width < 100: gst_logo = ascii_magic.from_image_file( "images/gst_logo_green_white_background.png", columns=50, width_ratio=2) else: gst_logo = ascii_magic.from_image_file("images/gst_letters.png", columns=console.console.width, width_ratio=2) ascii_magic.to_terminal(gst_logo) console.print( "[green]Thanks for using Gamestonk Terminal. This is our way![/green]\n" "\n" "[cyan]Join our community on discord: [/cyan]https://discord.gg/Up2QGbMKHY\n" "[cyan]Follow our twitter for updates: [/cyan]https://twitter.com/gamestonkt\n" "[cyan]Access our landing page: [/cyan]https://gamestonkterminal.github.io/GamestonkTerminal/\n" "\n" "[yellow]Partnerships:[/yellow]\n" "[cyan]FinBrain: [/cyan]https://finbrain.tech\n" "[cyan]Quiver Quantitative: [/cyan]https://www.quiverquant.com\n" "[cyan]SentimentInvestor: [/cyan]https://sentimentinvestor.com\n" "\n[red]" "DISCLAIMER: Trading in financial instruments involves high risks including the risk of losing some, " "or all, of your investment amount, and may not be suitable for all investors. Before deciding to trade in " "financial instrument you should be fully informed of the risks and costs associated with trading the financial " "markets, carefully consider your investment objectives, level of experience, and risk appetite, and seek " "professional advice where needed. The data contained in Gamestonk Terminal (GST) is not necessarily accurate. " "GST and any provider of the data contained in this website will not accept liability for any loss or damage " "as a result of your trading, or your reliance on the information displayed.[/red]\n" )
def School_Details(_school_svr, _save_logo, _print_logo): details_url = _school_svr + "?method=EduLink.SchoolDetails" details_body_raw = { "id":"1", "jsonrpc":"2.0", "method":"EduLink.SchoolDetails", "params":{ "establishment_id":"2", "from_app":False }, "uuid":str(uuid4()) } details_body = json.dumps(details_body_raw) details_headers = {"Content-Type":"application/json;charset=utf-8"} details_request = requests.post(details_url, data=details_body, headers=details_headers) # type requests.models.Response if "false" in Find_Info(details_request, "success", 1).lower(): exit(Find_Info(details_request, "error")) school_name = Find_Info(details_request, "name") school_logo_base64 = Find_Info(details_request, "logo") school_logo_64 = base64.b64decode(school_logo_base64) # type bytes file_directory = os.getcwd() + "/" file_name = school_name + " Logo.png" SCHOOL_LOGO_FILE_PATH = file_directory + file_name if _save_logo: with open (SCHOOL_LOGO_FILE_PATH, "wb") as f: f.write(school_logo_64) f.close() #To return converted image without saving; """ from PIL import Image import cv2 # Take in base64 string and return cv image def stringToRGB(school_logo_base64): school_logo = base64.b64decode(str(school_logo_base64)) image = Image.open(io.BytesIO(school_logo)) return cv2.cvtColor(np.array(image), cv2.COLOR_BGR2RGB) """ if _print_logo: school_logo_ascii = ascii_magic.from_image_file(SCHOOL_LOGO_FILE_PATH) ascii_magic.to_terminal(school_logo_ascii) return school_name
import ascii_magic output = ascii_magic.from_image_file('bean.jpg', columns=200, char='#') ascii_magic.to_terminal(output)
import ascii_magic # for leaf in [*range(10)] + [2]: print(f'{"X"*(leaf*2+1):^30}') print("\n\n\n") output = ascii_magic.from_image_file("python.jpg", columns=60, char="#") print(output) print("\n\n\n")
import ascii_magic output = ascii_magic.from_image_file('img/py2.jpg', mode=ascii_magic.Modes.HTML) ascii_magic.to_html_file('nicholas2.html', output,additional_styles='background: #222;')
async def set_ratio(message: Message, state: FSMContext): await state.update_data(ratio=message.text) username = message.from_user.username data = await state.get_data() columns = data.get("size") ratio = data.get("ratio") try: if float(ratio) < 0 or float( ratio) > 10: # If user entered incorrect number await message.answer("Chosen default ratio") await message.answer('Wait some seconds...') output = ascii_magic.from_image_file( f'docs/{username}/picture.png', columns=int(columns), mode=ascii_magic.Modes.HTML ) # Customization for default html doc ascii_magic.to_html_file(f'docs/{username}/ascii.html', output) # Reversing from image to html imgkit.from_file( f'docs/{username}/ascii.html', f'docs/{username}/html.png') # Screenshot from html page ########################################################################################### # Cropping Image # image = Image.open(f'docs/{username}/html.png') width, height = image.size # Cropping coordinates left = 8 top = 16 right = width bottom = height - top # Cropped image of above dimension im = image.crop((left, top, right, bottom)) # Shows the image in image viewer im.save(f'docs/{username}/html.png') ########################################################################################### size_b = os.path.getsize( f'docs/{username}/html.png') # Size of screenshot in bytes size_mb = size_b / 1_000_000 # Size of screenshot in mb await message.answer('Done! Sending ...') if size_mb < 10: # restriction of Telegram. Image can't be more than 10mb await message.answer_photo( InputFile(path_or_bytesio=f'docs/{username}/html.png')) await message.answer_document( InputFile(f'docs/{username}/html.png')) await message.answer_document( InputFile(f'docs/{username}/ascii.html')) else: await message.answer( 'So big size of photo. Sending only photo-document...') await message.answer_document( InputFile(f'docs/{username}/html.png')) await message.answer_document( InputFile(f'docs/{username}/ascii.html')) await message.delete() shutil.rmtree(f'docs/{username}/') # Removing dir with user files else: # If user entered correct number await message.answer("Chosen default ratio") await message.answer('Wait some seconds...') output = ascii_magic.from_image_file( f'docs/{username}/picture.png', columns=int(columns), width_ratio=float(ratio), mode=ascii_magic.Modes.HTML ) # Customization for default html doc ascii_magic.to_html_file(f'docs/{username}/ascii.html', output) # Reversing from image to html imgkit.from_file( f'docs/{username}/ascii.html', f'docs/{username}/html.png') # Screenshot from html page ########################################################################################### # Cropping Image # image = Image.open(f'docs/{username}/html.png') width, height = image.size # Cropping coordinates left = 8 top = 16 right = width bottom = height - top # Cropped image of above dimension im = image.crop((left, top, right, bottom)) # Shows the image in image viewer im.save(f'docs/{username}/html.png') ########################################################################################### size_b = os.path.getsize( f'docs/{username}/html.png') # Size of screenshot in bytes size_mb = size_b / 1_000_000 # Size of screenshot in mb await message.answer('Done! Sending ...') if size_mb < 10: # restriction of Telegram. Image can't be more than 10mb await message.answer_photo( InputFile(path_or_bytesio=f'docs/{username}/html.png')) await message.answer_document( InputFile(f'docs/{username}/html.png')) await message.answer_document( InputFile(f'docs/{username}/ascii.html')) else: await message.answer( 'So big size of photo. Sending only photo-document...') await message.answer_document( InputFile(f'docs/{username}/html.png')) await message.answer_document( InputFile(f'docs/{username}/ascii.html')) await message.delete() shutil.rmtree(f'docs/{username}/') # Removing dir with user files except ValueError: # If user entered characters instead digits await message.answer("Chosen default ratio") await message.answer('Wait some seconds...') output = ascii_magic.from_image_file( f'docs/{username}/picture.png', columns=int(columns), mode=ascii_magic.Modes.HTML) # Customization for default html doc ascii_magic.to_html_file(f'docs/{username}/ascii.html', output) # Reversing from image to html imgkit.from_file( f'docs/{username}/ascii.html', f'docs/{username}/html.png') # Screenshot from html page ########################################################################################### # Cropping Image # image = Image.open(f'docs/{username}/html.png') width, height = image.size # Cropping coordinates left = 8 top = 16 right = width bottom = height - top # Cropped image of above dimension im = image.crop((left, top, right, bottom)) # Shows the image in image viewer im.save(f'docs/{username}/html.png') ########################################################################################### size_b = os.path.getsize( f'docs/{username}/html.png') # Size of screenshot in bytes size_mb = size_b / 1_000_000 # Size of screenshot in mb await message.answer('Done! Sending ...') if size_mb < 10: # restriction of Telegram. Image can't be more than 10mb await message.answer_photo( InputFile(path_or_bytesio=f'docs/{username}/html.png')) await message.answer_document( InputFile(f'docs/{username}/html.png')) await message.answer_document( InputFile(f'docs/{username}/ascii.html')) else: await message.answer( 'So big size of photo. Sending only photo-document...') await message.answer_document( InputFile(f'docs/{username}/html.png')) await message.answer_document( InputFile(f'docs/{username}/ascii.html')) await message.delete() shutil.rmtree(f'docs/{username}/') # Removing dir with user files await state.finish()
for imn in s + '\n': sys.stdout.write(imn) sys.stdout.flush() time.sleep(000000.05) ddd(''' Here is some help to protect yourself As the first advice, do not do what someone asks for you, as sometimes he may take advantage of you The second tip is not to download apps from unauthorized sites In the event that you are hacked, shut down the network, remove the SIM card, and turn off your phone. Goodbye ''') elif tp == 'img': sec = input('TISD7R⟩⟩ ') sen = input('TA7R⟩⟩ ') siz = int(input('TS7R⟩⟩ ')) omn = ascii_magic.from_image_file(sec, columns=siz, char=sen) print(omn) elif tp == 'pkg': os.system('pkg install python -y') os.system('pkg install bash -y') os.system('pkg install python2 -y') os.system('pkg install python3 -y') os.system('pkg install clang -y') os.system('pkg install tor -y') os.system('pkg install repo -y') os.system('pkg install get -y') elif tp == 'hide sd (/))) \m HIDE cdr ()': xcn = input( 'If you continue, your device’s internal memory will be deleted') if xcn == 'continue()': os.system('cd /sdcard')
import ascii_magic output = ascii_magic.from_image_file("Sour.jpg", columns=175, char=".") ascii_magic.to_terminal(output)