Skip to content

Instantly share code, notes, and snippets.

@smtchahal
Last active August 14, 2020 17:34
Show Gist options
  • Select an option

  • Save smtchahal/893e88fa9a778f559fe73c2a6ef1764e to your computer and use it in GitHub Desktop.

Select an option

Save smtchahal/893e88fa9a778f559fe73c2a6ef1764e to your computer and use it in GitHub Desktop.

Revisions

  1. smtchahal revised this gist Mar 23, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion convert.py
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ def main():
    if os.path.isfile(name):
    convert(name)
    else:
    print('WARNING: {} is not a file'.format(name), file=sys.stdout)
    print('WARNING: {} is not a file'.format(name), file=sys.stderr)


    if __name__ == '__main__':
  2. smtchahal revised this gist Mar 3, 2018. 1 changed file with 0 additions and 0 deletions.
    Empty file modified convert.py
    100644 → 100755
    Empty file.
  3. smtchahal revised this gist Mar 3, 2018. No changes.
  4. smtchahal created this gist Mar 3, 2018.
    32 changes: 32 additions & 0 deletions convert.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #!/usr/bin/env python3

    # Converts GTA V's snapmatic files to JPG files.
    # It basically removes the first 292 bytes from the file.
    #
    # Usage: python3 convert.py file1 file2 file3...
    #
    # Output is stored as file1.jpg, file2.jpg, file3.jpg
    # in the same directory.

    import os
    import sys

    OFFSET = 292


    def convert(name):
    with open(name, 'rb') as in_file:
    with open(name + '.jpg', 'wb') as out_file:
    out_file.write(in_file.read()[OFFSET:])


    def main():
    for name in sys.argv[1:]:
    if os.path.isfile(name):
    convert(name)
    else:
    print('WARNING: {} is not a file'.format(name), file=sys.stdout)


    if __name__ == '__main__':
    main()