Small fix of PNG metadata storage, added metadata support to pixelterm
This commit is contained in:
parent
050fdb036d
commit
1b96018334
2 changed files with 9 additions and 4 deletions
|
|
@ -41,10 +41,10 @@ def termify_pixels(img):
|
|||
|
||||
def balloon(x,y):
|
||||
if x+1 == img.size[0] or img.getpixel((x+1, y)) != (0,255,0,127):
|
||||
w = 0
|
||||
w = 1
|
||||
while x-w >= 0 and img.getpixel((x-w, y)) == (0,255,0,127):
|
||||
w += 1
|
||||
return '$balloon{}$'.format(w+1)
|
||||
return '$balloon{}$'.format(w)
|
||||
return ''
|
||||
|
||||
for y in range(0, sy, 2):
|
||||
|
|
@ -87,7 +87,12 @@ if __name__ == '__main__':
|
|||
print(f)
|
||||
foo, _, _ = f.rpartition('.png')
|
||||
output = os.path.join(args.output_dir, os.path.basename(foo)+'.pony')
|
||||
metadata = '$$$\n' +\
|
||||
'\n'.join([ k.upper()+': '+img.info[k] for k in sorted(img.info.keys()) if k != 'comment' ]) +\
|
||||
'\n' + img.info.get('comment', '') +\
|
||||
'\n$$$\n'
|
||||
with open(output, 'w') as of:
|
||||
of.write(metadata)
|
||||
of.write(termify_pixels(img))
|
||||
else:
|
||||
print(termify_pixels(img))
|
||||
|
|
|
|||
|
|
@ -50,10 +50,10 @@ def unpixelterm(text):
|
|||
k,v = parts
|
||||
if k not in ['WIDTH', 'HEIGHT']:
|
||||
d[k.lower()] = d.get(k.lower(), []) + [v]
|
||||
elif l != '':
|
||||
else:
|
||||
comment.append(l)
|
||||
if comment:
|
||||
d['comment'] = d.get('comment', []) + comment
|
||||
d['comment'] = d.get('comment', []) + ['\n'.join(comment)]
|
||||
metadata.update(d)
|
||||
lines[first:] = lines[first+1+second+1:]
|
||||
except:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue