Skip to content

Instantly share code, notes, and snippets.

@themixray
Last active December 14, 2021 08:36
Show Gist options
  • Save themixray/b8c059c2d06ac8524eb089a7815aca45 to your computer and use it in GitHub Desktop.
Save themixray/b8c059c2d06ac8524eb089a7815aca45 to your computer and use it in GitHub Desktop.
from tkinter import filedialog
from tkinter import Tk
import pickle
import pygame
import bz2
import os
os.system('cls')
def ofd():
root = Tk()
root.withdraw()
f = filedialog.askopenfilename()
root.destroy()
return f
d = pygame.image.load(ofd())
d = [pygame.image.tostring(d,"RGBA"),d.get_size()]
d = bz2.compress(pickle.dumps(d))
print(f'import bz2,pickle,pygame;img=pygame.image.fromstring(*pickle.loads(bz2.decompress({repr(d)})),"RGBA");del bz2,pickle,pygame')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment