-
-
Save omers4/9e7d90ee605e6545965c0f2f2a55f037 to your computer and use it in GitHub Desktop.
Python script that allows to change Gif animation loop count
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import re | |
| import binascii | |
| pattern = b"\x4E\x45\x54\x53\x43\x41\x50\x45\x32\x2E\x30" | |
| regex = re.compile(pattern) | |
| rep = sys.argv[2] | |
| with open(sys.argv[1], 'r+b') as f: | |
| content = f.read() | |
| for match_obj in regex.finditer(content): | |
| offset = match_obj.start() | |
| print("New repetitions value: " + rep) | |
| f.seek(offset + 13) | |
| nRep = hex(int(rep, 10)) | |
| f.write(binascii.unhexlify(nRep[2:].zfill(2))) | |
| print('Done.') | |
| input("Press Enter to continue...") |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adjusted for Python 3