Skip to content

Instantly share code, notes, and snippets.

@bibliotechy
Created February 18, 2013 17:30
Show Gist options
  • Save bibliotechy/4979053 to your computer and use it in GitHub Desktop.
Save bibliotechy/4979053 to your computer and use it in GitHub Desktop.
Takes the output of running pngnq on a file and returns it to its original filename.
#!/usr/bin/python
# Filename: denq.py
from os import path
import shutil
import sys
def main():
if sys.argv:
base = sys.argv[1] #get the filename from shell
fullpath = path.split(base)
filename = fullpath[1].split('-')[0] #pngng creates files with -nq before the .png
#now move the quantized photo to replace the existing photo
shutil.move(base,fullpath[0]+'/'+filename+".png")
else:
print "No file supplied, quitting"
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment