コード例 #1
0
ファイル: __init__.py プロジェクト: kcsaff/CA
def read(filename, file=None):
    if filename.endswith('.zip'):
        import native
        return native.read(filename, file)
    elif filename.endswith('.mcl'):
        import mcell
        return mcell.read(filename, file)
    elif filename.endswith('.png'):
        import png
        return png.read(filename, file)
    elif filename.endswith('.fits'):
        import fits
        return fits.read(filename, file)
    elif filename.startswith('meta') and filename.endswith('txt'):
        import meta
        return meta.read(filename, file)
    else:
        raise ValueError, 'Do not understand how to read file "%s"' % filename
コード例 #2
0
ファイル: png-examples.py プロジェクト: liuwanjie/corkami
import sys, zlib, os
from Crypto.Cipher import AES
import png

with open("logo11w.png", "rb") as f:
    c = png.read(f)

# a PNG with appended data
contents = png.make(c) + os.urandom(64 * 1024)
with open("appendeddata.png", "wb") as f:
    f.write(contents)

# a PNG with a standard text chunk
c1 = list(c)
c1.insert(1, ["tEXt", "sans commentaire!"])

with open("text-chunk.png", "wb") as f:
    f.write(png.make(c1))

# a PNG with a custom chunk
c2 = list(c)
c2.insert(1, ["bing", "extra chunk"])

with open("custom-chunk.png", "wb") as f:
    f.write(png.make(c2))

# a PNG with a custom chunk FIRST
c2 = list(c)
c2.insert(0, ["brin", "Do no evil, Sergey ;)"])

with open("custom-first.png", "wb") as f:
コード例 #3
0
ファイル: decode.py プロジェクト: yokeshwar93/browsershots
import sys, png

width, height, pixels = png.read(sys.stdin)
print 'P6 %s %s 255' % (width, height)
pixels.tofile(sys.stdout)
コード例 #4
0
#appends data at PNG format level

import sys, png, os

fn = sys.argv[1]

with open(fn, "rb") as f:
    chunks = png.read(f)

for chunk in chunks:
    if chunk[0] == "IDAT":
        chunk[1] += os.urandom(1024 * 1024)

with open("app_%s" % fn, "wb") as f:
    f.write(png.make(chunks))
コード例 #5
0
ファイル: png_app_data.py プロジェクト: liuwanjie/corkami
# appends data at PNG format level

import sys, png, os

fn = sys.argv[1]

with open(fn, "rb") as f:
    chunks = png.read(f)

for chunk in chunks:
    if chunk[0] == "IDAT":
        chunk[1] += os.urandom(1024 * 1024)

with open("app_%s" % fn, "wb") as f:
    f.write(png.make(chunks))
コード例 #6
0
import sys, zlib, os
from Crypto.Cipher import AES
import png

with open("logo11w.png", "rb") as f:
    c = png.read(f)

#a PNG with appended data
contents = png.make(c) + os.urandom(64 * 1024)
with open("appendeddata.png", "wb") as f:
    f.write(contents)

#a PNG with a standard text chunk
c1 = list(c)
c1.insert(1, ["tEXt", "sans commentaire!"])

with open("text-chunk.png", "wb") as f:
    f.write(png.make(c1))

#a PNG with a custom chunk
c2 = list(c)
c2.insert(1, ["bing", "extra chunk"])

with open("custom-chunk.png", "wb") as f:
    f.write(png.make(c2))

#a PNG with a custom chunk FIRST
c2 = list(c)
c2.insert(0, ["brin", "Do no evil, Sergey ;)"])

with open("custom-first.png", "wb") as f: