Skip to content

Instantly share code, notes, and snippets.

@AndyNovo
Created October 6, 2021 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndyNovo/31698cd5256b049231f988f84502ccc6 to your computer and use it in GitHub Desktop.
Save AndyNovo/31698cd5256b049231f988f84502ccc6 to your computer and use it in GitHub Desktop.
from PIL import Image
im=Image.open("imgflag.png")
w,h=im.size
pixels=[]
for i in range(w):
for j in range(h):
pixels.append(im.getpixel((i,j)))
f=file("loader.sql","w")
f.write("create table size (height int, width int);\n")
f.write("insert into size values (%d, %d);\n" % (w,h))
f.write("create table pixels (indx integer primary key autoincrement, red integer, green integer, blue integer);\n")
for triple in pixels:
f.write("insert into pixels (red, green, blue) values (%d, %d, %d);\n" % triple)
f.close()
import os
os.system("sqlite3 flag.db < loader.sql")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment