SHARE
TWEET

fotogenerator.npocloud.nl

a guest Jun 11th, 2017 225 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # 0. install python 3.6.0
  2. # 1. > pip install pillow
  3. # 2. run this
  4. # 3. select picture
  5. # 4. go to http://fotogenerator.npocloud.nl/
  6. # 5. press F12
  7. # 6. paste to console
  8. # 7. ???
  9. # 8. profit!
  10.  
  11. import base64
  12. from PIL import Image, ImageFilter
  13. import tkinter as tk
  14. from tkinter import filedialog, messagebox
  15.  
  16. root = tk.Tk()
  17. root.withdraw()
  18.  
  19. def get_path():
  20.     file_path = filedialog.askopenfilename(filetypes = (('Images', '*.jpg *.png'), ('JPEG', '*.jpg'), ('PNG', '*.png')))
  21.     return file_path
  22.  
  23.  
  24. input_image = Image.open(get_path())
  25.  
  26. # edges
  27. input_image = input_image.filter(ImageFilter.CONTOUR)
  28.  
  29. # crop
  30. width, height = input_image.size   # Get dimensions
  31. new_width = new_height = min(width, height)
  32. left = (width - new_width)/2
  33. top = (height - new_height)/2
  34. right = (width + new_width)/2
  35. bottom = (height + new_height)/2
  36. input_image = input_image.crop((left, top, right, bottom))
  37.  
  38. # resize
  39. resized_image = input_image.resize((256, 256), Image.ANTIALIAS)
  40. resized_image.save('output.png')
  41.  
  42. # base64
  43. with open('output.png', 'rb') as b64_image:
  44.     encoded_string = base64.b64encode(b64_image.read())
  45.  
  46. b64_output = '''(() => {{
  47. let img = new Image();
  48. img.onload = () => editors[0].buffer.drawImage(img, 0, 0);
  49. img.src='data:image\/png;base64,{0}';
  50. }})();'''.format(encoded_string.decode('utf-8'))
  51.  
  52.  
  53. # save    
  54. #with open('base64.txt', 'w') as txt_file:
  55. #    txt_file.write(b64_output)
  56.  
  57. root.clipboard_clear()
  58. root.clipboard_append(b64_output)
  59. root.update()  # now it stays on the clipboard after the window is closed
  60. messagebox.showinfo("Success!", "Command was copied to clipboard")
  61. root.destroy()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top