- 浏览: 440363 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (538)
- C/C++ Primer (69)
- Objective-C Primer (102)
- Python Primer (19)
- JavaScript Primer (1)
- Java Primer (37)
- PHP Primer (17)
- 泛 Linux (37)
- Shell Script (21)
- APUE (21)
- UNP__1&2 (19)
- NetWork (7)
- Oracle周边 (38)
- Mysql里边 (6)
- Windows技 (9)
- 简单算法 & 数据结构 (14)
- 设计模式 (6)
- GTK历程 (12)
- 工具使用 (25)
- 杂事 (23)
- 一些概念 (17)
- Web方面 (10)
- myCodeTools (9)
- ^未 竟$ (13)
- 硬件通信 (2)
- Games (1)
最新评论
app PNG
- 博客分类:
- Python Primer
#---
# iPIN - iPhone PNG Images Normalizer v1.0
# Copyright (C) 2007
#
# Author:
# Axel E. Brzostowski
# http://www.axelbrz.com.ar/
# axelbrz@gmail.com
#
# References:
# http://iphone.fiveforty.net/wiki/index.php/PNG_Images
# http://www.libpng.org/pub/png/spec/1.2/PNG-Contents.html
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#---
from struct import *
from zlib import *
import stat
import sys
import os
def getNormalizedPNG(filename):
pngheader = "\x89PNG\r\n\x1a\n"
file = open(filename, "rb")
oldPNG = file.read()
file.close()
if oldPNG[:8] != pngheader:
return None
newPNG = oldPNG[:8]
chunkPos = len(newPNG)
# For each chunk in the PNG file
while chunkPos < len(oldPNG):
# Reading chunk
chunkLength = oldPNG[chunkPos:chunkPos+4]
chunkLength = unpack(">L", chunkLength)[0]
chunkType = oldPNG[chunkPos+4 : chunkPos+8]
chunkData = oldPNG[chunkPos+8:chunkPos+8+chunkLength]
chunkCRC = oldPNG[chunkPos+chunkLength+8:chunkPos+chunkLength+12]
chunkCRC = unpack(">L", chunkCRC)[0]
chunkPos += chunkLength + 12
# Parsing the header chunk
if chunkType == "IHDR":
width = unpack(">L", chunkData[0:4])[0]
height = unpack(">L", chunkData[4:8])[0]
# Parsing the image chunk
if chunkType == "IDAT":
try:
# Uncompressing the image chunk
bufSize = width * height * 4 + height
chunkData = decompress( chunkData, -8, bufSize)
except Exception, e:
# The PNG image is normalized
return None
# Swapping red & blue bytes for each pixel
newdata = ""
for y in xrange(height):
i = len(newdata)
newdata += chunkData[i]
for x in xrange(width):
i = len(newdata)
newdata += chunkData[i+2]
newdata += chunkData[i+1]
newdata += chunkData[i+0]
newdata += chunkData[i+3]
# Compressing the image chunk
chunkData = newdata
chunkData = compress( chunkData )
chunkLength = len( chunkData )
chunkCRC = crc32(chunkType)
chunkCRC = crc32(chunkData, chunkCRC)
chunkCRC = (chunkCRC + 0x100000000) % 0x100000000
# Removing CgBI chunk
if chunkType != "CgBI":
newPNG += pack(">L", chunkLength)
newPNG += chunkType
if chunkLength > 0:
newPNG += chunkData
newPNG += pack(">L", chunkCRC)
# Stopping the PNG file parsing
if chunkType == "IEND":
break
return newPNG
def updatePNG(filename):
data = getNormalizedPNG(filename)
if data != None:
file = open(filename, "wb")
file.write(data)
file.close()
return True
return data
def getFiles(base):
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
# iPIN - iPhone PNG Images Normalizer v1.0
# Copyright (C) 2007
#
# Author:
# Axel E. Brzostowski
# http://www.axelbrz.com.ar/
# axelbrz@gmail.com
#
# References:
# http://iphone.fiveforty.net/wiki/index.php/PNG_Images
# http://www.libpng.org/pub/png/spec/1.2/PNG-Contents.html
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#---
from struct import *
from zlib import *
import stat
import sys
import os
def getNormalizedPNG(filename):
pngheader = "\x89PNG\r\n\x1a\n"
file = open(filename, "rb")
oldPNG = file.read()
file.close()
if oldPNG[:8] != pngheader:
return None
newPNG = oldPNG[:8]
chunkPos = len(newPNG)
# For each chunk in the PNG file
while chunkPos < len(oldPNG):
# Reading chunk
chunkLength = oldPNG[chunkPos:chunkPos+4]
chunkLength = unpack(">L", chunkLength)[0]
chunkType = oldPNG[chunkPos+4 : chunkPos+8]
chunkData = oldPNG[chunkPos+8:chunkPos+8+chunkLength]
chunkCRC = oldPNG[chunkPos+chunkLength+8:chunkPos+chunkLength+12]
chunkCRC = unpack(">L", chunkCRC)[0]
chunkPos += chunkLength + 12
# Parsing the header chunk
if chunkType == "IHDR":
width = unpack(">L", chunkData[0:4])[0]
height = unpack(">L", chunkData[4:8])[0]
# Parsing the image chunk
if chunkType == "IDAT":
try:
# Uncompressing the image chunk
bufSize = width * height * 4 + height
chunkData = decompress( chunkData, -8, bufSize)
except Exception, e:
# The PNG image is normalized
return None
# Swapping red & blue bytes for each pixel
newdata = ""
for y in xrange(height):
i = len(newdata)
newdata += chunkData[i]
for x in xrange(width):
i = len(newdata)
newdata += chunkData[i+2]
newdata += chunkData[i+1]
newdata += chunkData[i+0]
newdata += chunkData[i+3]
# Compressing the image chunk
chunkData = newdata
chunkData = compress( chunkData )
chunkLength = len( chunkData )
chunkCRC = crc32(chunkType)
chunkCRC = crc32(chunkData, chunkCRC)
chunkCRC = (chunkCRC + 0x100000000) % 0x100000000
# Removing CgBI chunk
if chunkType != "CgBI":
newPNG += pack(">L", chunkLength)
newPNG += chunkType
if chunkLength > 0:
newPNG += chunkData
newPNG += pack(">L", chunkCRC)
# Stopping the PNG file parsing
if chunkType == "IEND":
break
return newPNG
def updatePNG(filename):
data = getNormalizedPNG(filename)
if data != None:
file = open(filename, "wb")
file.write(data)
file.close()
return True
return data
def getFiles(base):
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
发表评论
-
webpy_Cookbook
2013-05-06 22:31 573http://webpy.org/cookbook/index ... -
webpy_CGI 伏笔
2013-05-06 10:18 1089http://webpy.org/install.zh-cn ... -
python__re
2013-03-19 17:49 573xpath解析html,使用正则不好... http://ww ... -
Django
2013-03-03 20:04 957https://docs.djangoproject.com/ ... -
bpython IDE
2013-02-27 11:51 648http://bpython-interpreter.org/ ... -
install webpy
2012-07-20 20:58 568http://webpy.org/install.zh-cn ... -
python__zip
2012-06-14 10:26 626前几天用了下zip,要压缩个目录,下面那坨代码也是copy回 ... -
Python__列表
2011-02-12 14:23 600http://gmingzhe.blog.51cto.com/ ... -
Python__参数:传值or引用?
2011-02-12 14:20 588http://blog.csdn.net/winterTTr/ ... -
Python__递归遍历文件
2011-02-12 12:54 798http://zhangjunhd.blog.51cto.co ... -
Python__升级
2011-02-12 10:57 886http://www.activestate.com/ 出处 ... -
Python__模块
2011-02-11 15:48 742什么是模块:sys、time等模块,已经被封装起来,我们经常在 ... -
Python__函数
2011-02-11 15:18 674最基本函数 #!/usr/bin/python de ... -
Python__时间
2011-02-11 15:15 552当前时间 遍历时间 时间截 -
常用模块介绍
2010-07-22 15:48 609http://blog.csdn.net/Xiao_Qiang ... -
python编码相关
2010-07-22 09:54 957http://blog.csdn.net/lwl_ls/arc ... -
Python函数库列表
2010-07-21 21:05 1249copy:http://blog.ez2learn.com ... -
python__init
2010-05-27 10:22 584http://blog.sina.com.cn/s/artic ...
相关推荐
各大银行的png图片及银行缩写英文,this resources include banks png and short name
图标 PNG图标 APP开发专用图标 有各种规格大小的PNG图标 精美图标
UI素材 ICON素材 APP素材 PNG素材包 5G素材包 psd素材包
商家APP.png
app支付交易流程图,java编程及示例,欢迎下载,谢谢
PNG格式头像,每张头像图大小 50kb 左右,使用场景:各类APP用户头像、网站用户头像等等均可,分辨率:160 * 160,位深度:32
沃尔特与iOS的法国红酒荣誉我我的风格环境看玩儿推儿童与你沃尔特与iOS的法国红酒荣誉我我的风格环境看玩儿推儿童与你沃尔特与iOS的法国红酒荣誉我我的风格环境看玩儿推儿童与你沃尔特与iOS的法国红酒荣誉我我的风格...
村小爱app信息结构.png
1000个常用精美软件图标,适合网站、ERP软件,PNG图标。 128X128
项目经验-APP思维导图.png
提取IOS App及游戏中的PNG图片.由于Xcode在打包程序时对图片进行了优化,导致部分图片提取后不能正常显示,该工具能够修复优化后的图片,使其能正常使用,内附脚步一个及使用步骤
app测试用例完整版
一起学——手机APP模块方案.png
BluetoothThis APP is a demo for bluetooth,which can transmit messages and files in the end.这是一个简单蓝牙APP,主要功能有扫描、配对;传输信息和文件。开发工具此APP开发的IDE为Android Studio 3.0APP截图
Aber Taxi App UI Kit.xd png Booking Details.png Booking Successfully.png Choose Drop-off with map.png Choose Drop-off.png Choose Vehicle type_Full view.png Choose Vehicle type.png Home.png Input Promo...
适用于iOS系统的App图标输出模板,只需要制作一张 512*512尺寸的图标,借助文件夹中的psd文件并导入附带的ps脚本即可完成多种尺寸的图标输出,一步到位 省去制作多个不同尺寸图标的麻烦。 操作步骤 1 在ps中导入...
7000个图标_16X16_32X32_Icon_PNG 软件开发,APP开发常用图标,淘定上花钱买来的..
APP,手机客户端的原型流程图,纪念日流程。
png 01.png 02.png 03.png A0.png A1.png A2.png A3.png A4.png A5.png A6.png A7.png A8.png All slicing assets.png B0 Home_empty list.png B0 Home.png B1.png B2.png B3.png B4.png B5.png B6.png B7.png C1....
png蕾丝.rar 很好的PS制图插件,特别是制作音画作品。