Created
September 29, 2015 21:05
-
-
Save Kurobyte/956239fbd35d6d53c8a2 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
| # Change GIF nº animation loop count | |
| # Usage: python script.py "path-to-image" <number> | |
| # | |
| # Number: 0 to infinite loop. Enter other number to set that loop count | |
| import sys, re; | |
| import binascii; | |
| pattern = "\x4E\x45\x54\x53\x43\x41\x50\x45\x32\x2E\x30"; | |
| regex = re.compile(pattern); | |
| rep = sys.argv[2]; | |
| f = open(sys.argv[1], 'r+b'); | |
| for match_obj in regex.finditer(f.read()): | |
| offset = match_obj.start(); | |
| print "New repetitions value: "+rep; | |
| f.seek(offset + 13); | |
| nRep = hex(int(rep, 10)); | |
| f.write(nRep); | |
| print 'Done.'; | |
| raw_input("Press Enter to continue..."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
THANK YOU