mirror of https://github.com/dirtbags/moth.git
Add 1000-point compaq puzzle; rename puzzle files
This commit is contained in:
parent
a6dcbdcdf9
commit
dbd9aea6f1
|
@ -0,0 +1,57 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
import zipfile
|
||||
import pyexiv2
|
||||
import os
|
||||
import random
|
||||
import shutil
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
basedir = 'src'
|
||||
|
||||
jpegs = os.listdir(basedir)
|
||||
jpegs.append(jpegs[0])
|
||||
jpegs.append(jpegs[1])
|
||||
jpl = len(jpegs)
|
||||
|
||||
payload = open('payload.zip').read()
|
||||
pll = len(payload)
|
||||
|
||||
chunksize = pll / jpl
|
||||
chunks = []
|
||||
while payload:
|
||||
chunk = pyexiv2.StringToUndefined(payload[:chunksize])
|
||||
chunks.append(chunk)
|
||||
payload = payload[chunksize:]
|
||||
|
||||
date_time = (2009, 8, 20, 9, 15)
|
||||
seconds = 12
|
||||
ofiles = []
|
||||
for fn in jpegs:
|
||||
src = open(os.path.join(basedir, fn))
|
||||
dst = tempfile.NamedTemporaryFile(prefix='img', suffix='.jpg')
|
||||
shutil.copyfileobj(src, dst)
|
||||
dst.flush()
|
||||
|
||||
# Write exif chunk
|
||||
chunk = chunks.pop(0)
|
||||
i = pyexiv2.Image(dst.name)
|
||||
i.readMetadata()
|
||||
i['Exif.Image.0x1663'] = chunk
|
||||
i.writeMetadata()
|
||||
|
||||
timestamp = date_time + (seconds,)
|
||||
zinfo = zipfile.ZipInfo(os.path.basename(dst.name), timestamp)
|
||||
zinfo.external_attr = 0644 << 16
|
||||
ofiles.append((dst.name, dst, zinfo))
|
||||
seconds += 1
|
||||
|
||||
ofiles.sort()
|
||||
|
||||
zip = zipfile.ZipFile('out.zip', 'w')
|
||||
for _, f, zinfo in ofiles:
|
||||
f.seek(0)
|
||||
zip.writestr(zinfo, f.read())
|
||||
|
||||
print('whew!')
|
|
@ -0,0 +1 @@
|
|||
PEANUT BUTTER JELLY TIME
|
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
PEANUT BUTTER JELLY TIME
|
Loading…
Reference in New Issue