跳转到主要内容

RECOIL库的Python绑定,Retro Computer Image Library

项目描述

pyrecoilRECOIL(Retro Computer Image Library)提供Python绑定,允许您打开来自复古计算机的500多种图像文件格式。

安装

pip install pyrecoil

pyrecoilPillow(Python Image Library的活跃分支)一起安装时最为有用。

pip install Pillow

使用方法

from recoil import RecoilImage

# load image from disk and decode it:
img = RecoilImage("foo.lbm")

# load image from an existing file handle:
# (filename must still be provided, as a hint to the decoder)
img = RecoilImage("foo.lbm", f)

# inspecting properties:
img.colors  # number of colors used in the image
> 16

img.frames  # number of alternating frames (used for 'interlace' / 'gigascreen' effects)
> 1

img.size  # return a tuple of (width, height)
> (320, 200)

img.original_size  # for images that have been resized to account for non-square pixels
> (320, 200)

img.platform
> 'Amiga'

# Retrieving pixel data -
# returns a bytearray consisting of three bytes (r, g, b) for each pixel,
# in left-to-right, top-to-bottom order
pixels = img.get_pixels()

# convert to a PIL / Pillow image object:
pil_image = img.to_pil()
pil_image.save('foo.png')

构建说明

RECOIL库本身是用 Fusion编程语言 实现的。为了便于分发,包含在包中的C输出(recoil.crecoil.h)来自 fut 编译器,以及 recoil_interface.c,共同构成了Python扩展模块。

作者

Matt Westcott - matt@west.co.tthttp://twitter.com/gasmanic

由以下支持