Skip to content

Instantly share code, notes, and snippets.

@leonidk
Last active November 8, 2016 23:32
Show Gist options
  • Save leonidk/0f883526acff7ea23c3f to your computer and use it in GitHub Desktop.
Save leonidk/0f883526acff7ea23c3f to your computer and use it in GitHub Desktop.
Google Lens Blur Format
import base64
import sys
import os
def processFile(fileName):
f = open(fileName,'rb').read()
x = [('GDepth:Data','.jpg'),('GImage:Data','.jpg')]
for c in x:
start_pos = f.find(c[0])
if start_pos < 0:
continue;
data = f[start_pos+13:]
while data.count('\xff\xe1') > 0:
pos = data.find('\xff\xe1')
data = data[:pos] + data[pos+79:]
end_pos = data.find('\"')
if end_pos < 0:
continue;
data = data[:end_pos]
try:
data2 = base64.b64decode(data)
fOut = open(fileName[:-4]+c[0][1:6] + c[1],'wb')
fOut.write(data2)
fOut.close()
except:
print 'Failed on ', fileName, c[0][1:6], len(data)
if sys.argv[-1][-2:] == 'py':
for file in os.listdir('.'):
if file[-3:] == 'jpg':
processFile(file)
elif sys.argv[-1][-3:] == 'jpg':
processFile(sys.argv[-1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment