def deretina(dir,file): # filepath = os.path.join(dir,file) iWidth = imageWidth(filepath) iHeight = imageHeight(filepath) outWidth, outHeight = canDeretina(iWidth,iHeight) if not outWidth or not outHeight: print "Can't deretina "+filepath+' ('+iWidth+', '+iHeight+')' return else: unretFilename = file.replace('@2x','') if not os.path.exists(os.path.join(dir,unretFilename)) or should_overwrite_existing_files == True: print "Deretina-ing "+filepath+' ('+iWidth+', '+iHeight+')' doCmd = 'sips -z {} {} {} --out {}'.format( outHeight, outWidth, commands.mk2arg('',filepath), commands.mk2arg(dir,unretFilename )) status, output = commands.getstatusoutput(doCmd) else: print "Already deretina-ed "+filepath+' ('+iWidth+', '+iHeight+')'
def getProperty(filepath, property): status, output = commands.getstatusoutput('sips -g '+property+' '+commands.mk2arg('',filepath)) outputlist = output.split(property+': ') prop = outputlist.pop() return prop