diff options
Diffstat (limited to 'share/frontend/impattern/other_script.py')
| -rw-r--r-- | share/frontend/impattern/other_script.py | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/share/frontend/impattern/other_script.py b/share/frontend/impattern/other_script.py deleted file mode 100644 index a057646..0000000 --- a/share/frontend/impattern/other_script.py +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/python - -import downloader -import filenamer -import inventnamer -import fieldstorager -import hexdirer -import cgi -from subprocess import Popen, PIPE -import os -import sys - -print "Content-Type: text/html" -print -print "" - -nametag = "imDither" - -MAIN_DIRECTORY = "" -#BIN_CONVERT = "/usr/bin/convert" -#BIN_IDENTIFY = "/usr/bin/identify" -#BIN_COMPOSITE = "/usr/bin/composite" -BIN_CONVERT = "convert" -BIN_IDENTIFY = "identify" -BIN_COMPOSITE = "composite" - -PARAM_LIST = "theurl thedither username format" - -form = cgi.FieldStorage() -newvalues = fieldstorager.fieldstorage(PARAM_LIST, form) -thekeys = PARAM_LIST.split() -for key in thekeys: - globals()[key] = newvalues[key] - -if username == None: - username = "" - -################################### -### TEST WITH VALUES HERE -theurl = "http://asdf.us/im/10/friedeggstresstoy_1321140711_1322282769_pepper.gif" -thedither = "1.png" -username = "pepper" -format = "png" -################################### -if format == None: - format = "png" - -class Dither: - def file_size (self, file): - return os.stat(file)[6] - def identify(self, thefile): - ident = Popen([BIN_IDENTIFY, thefile], stdout=PIPE).communicate()[0] - partz = ident.split(" ") - return partz[2].split("x") - def makeCanvas(self, dimensions, thefile): - os.system(BIN_CONVERT+" -size "+self.dimensions[0]+"x"+self.dimensions[1]+" canvas:transparent "+thefile) - def makeMask(self, themask, thedither, thebackground): - os.system(BIN_COMPOSITE+" -tile "+thedither+" "+thebackground+" "+themask) - #convert thebg.gif -compose Dst_In null: thefile.gif -matte -layers composite new.gif - os.system(BIN_CONVERT+" "+themask+" -compose Dst_In null: "+self.mainfile+" -matte -layers composite "+themask) - # os.system("rm "+thebackground) - def fuseMask(self, themask, theimage): - os.system(BIN_COMPOSITE+" "+theimage+" -compose Pin_Light "+themask+" "+theimage) - # os.system("rm "+themask) - def __init__(self, theurl, thedither, username): - self.mainfile = filenamer.filename(theurl, "imDither", username) - filepaths = hexdirer.hexdir() - self.privatepath = filepaths[0] - self.publicpath = filepaths[1] - self.privatepath = "" # - downloader.download(theurl, self.mainfile, self.privatepath) - parts = self.mainfile.split('.') - print parts - if "gif" in parts[-1]: - canvastype = "gif" - else: - canvastype = "png" - self.canvasfile = inventnamer.inventname(canvastype, "canvasfile") - self.dimensions = self.identify(self.mainfile) - self.makeCanvas(self.dimensions, self.canvasfile) - self.theMask = inventnamer.inventname(canvastype, "maskfile") - self.makeMask(self.theMask, thedither, self.canvasfile) - self.fuseMask(self.theMask, self.mainfile) - #self.mainfile = self.mainfile.replace(, do something with s3) - print self.mainfile - print self.file_size(self.mainfile) - print 'width: '+self.dimensions[0]+'px' - print 'height: '+self.dimensions[1]+'px' -daddy = Dither(theurl, thedither, username) -
|
