WEB开发网
开发学院手机开发iPhone 开发 将iPhone的png图片转换为可读png图片的Python源码... 阅读

将iPhone的png图片转换为可读png图片的Python源码

 2010-06-19 18:34:00 来源:WEB开发网   
核心提示:global _dirsglobal _pngsif base == ".":_dirs = []_pngs = []if base in _dirs:returnfiles = os.listdir(base)for file in files:filepath = os.path.join(ba

global _dirs

global _pngs

if base == ".":

_dirs = []

_pngs = []

if base in _dirs:

return

files = os.listdir(base)

for file in files:

filepath = os.path.join(base, file)

try:

st = os.lstat(filepath)

except os.error:

continue

if stat.S_ISDIR(st.st_mode):

if not filepath in _dirs:

getFiles(filepath)

_dirs.append( filepath )

elif file[-4:].lower() == ".png":

if not filepath in _pngs:

_pngs.append( filepath )

if base == ".":

return _dirs, _pngs

print "-----------------------------------"

print " iPhone PNG Images Normalizer v1.0"

print "-----------------------------------"

print " "

print "[+] Searching PNG files...",

dirs, pngs = getFiles(".")

print "ok"

if len(pngs) == 0:

print " "

print "[!] Alert: There are no PNG files found. Move this python file to the folder that contains the PNG files to normalize."

exit()

print " "

print " - %d PNG files were found at this folder (and subfolders)." % len(pngs)

print " "

while True:

normalize = raw_input("[?] Do you want to normalize all images (Y/N)? ").lower()

if len(normalize) > 0 and (normalize[0] == "y" or normalize[0] == "n"):

break

normalized = 0

if normalize[0] == "y":

for ipng in xrange(len(pngs)):

perc = (float(ipng) / len(pngs)) * 100.0

print "%.2f%% %s" % (perc, pngs[ipng])

if updatePNG(pngs[ipng]):

normalized += 1

print " "

print "[+] %d PNG files were normalized." % normalized

上一页  1 2 3 

Tags:iPhone png 图片

编辑录入:coldstar [复制链接] [打 印]
赞助商链接