Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 0. install python 3.6.0
- # 1. > pip install pillow
- # 2. run this
- # 3. select picture
- # 4. go to http://fotogenerator.npocloud.nl/
- # 5. press F12
- # 6. paste to console
- # 7. ???
- # 8. profit!
- import base64
- from PIL import Image, ImageFilter
- import tkinter as tk
- from tkinter import filedialog, messagebox
- root = tk.Tk()
- root.withdraw()
- def get_path():
- file_path = filedialog.askopenfilename(filetypes = (('Images', '*.jpg *.png'), ('JPEG', '*.jpg'), ('PNG', '*.png')))
- return file_path
- input_image = Image.open(get_path())
- # edges
- input_image = input_image.filter(ImageFilter.CONTOUR)
- # crop
- width, height = input_image.size # Get dimensions
- new_width = new_height = min(width, height)
- left = (width - new_width)/2
- top = (height - new_height)/2
- right = (width + new_width)/2
- bottom = (height + new_height)/2
- input_image = input_image.crop((left, top, right, bottom))
- # resize
- resized_image = input_image.resize((256, 256), Image.ANTIALIAS)
- resized_image.save('output.png')
- # base64
- with open('output.png', 'rb') as b64_image:
- encoded_string = base64.b64encode(b64_image.read())
- b64_output = '''(() => {{
- let img = new Image();
- img.onload = () => editors[0].buffer.drawImage(img, 0, 0);
- img.src='data:image\/png;base64,{0}';
- }})();'''.format(encoded_string.decode('utf-8'))
- # save
- #with open('base64.txt', 'w') as txt_file:
- # txt_file.write(b64_output)
- root.clipboard_clear()
- root.clipboard_append(b64_output)
- root.update() # now it stays on the clipboard after the window is closed
- messagebox.showinfo("Success!", "Command was copied to clipboard")
- root.destroy()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement