Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from core.lib.png import Reader, Writer, write_chunks
- import pickle
- import sys
- from core.appfw.transforms import *
- filename = r"C:\path\to\image.png"
- r = Reader(filename=filename)
- #newChunk = ('tEXt',pickle.dumps([[Attributes.TYPE_SEARCH_PREV, {'value':Attributes.SPACIAL_ABOVE, 'proximity':50}]\
- # ]))
- #newChunk = ('tEXt',pickle.dumps([[Attributes.SIMILARITY, {'value':1.0}]]))
- transforms = {
- Transforms.CONTEXT_PREVIOUS: [ \
- RegionNearby(10),
- ], \
- Transforms.CONTEXT_CURRENT: [ \
- PatternSimilarity(0.75),
- # PatternTargetOffset(0,-10)
- ], \
- Transforms.CONTEXT_NEXT: [ \
- # RegionBelow(200),
- # RegionLeft()
- # RegionNearby(10)
- ] \
- }
- newChunk = ('tEXt',pickle.dumps(transforms))
- found = False
- chunks = []
- for chunk in r.chunks():
- print chunk
- if chunk[0] == 'tEXt':
- #print 'here', chunk
- chunk = newChunk
- found = True
- elif chunk[0] == 'IEND':
- if not found:
- chunks.append(newChunk)
- chunks.append(chunk)
- f=open(filename, 'wb')
- write_chunks(f, chunks)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement