用于处理paintshop pro文件的python包

psp-scan的Python项目详细描述


PSP U扫描

这是一个用于读取paintshop pro文件(.pspimage)的库,并且 转换为BMP或PNG。任何保存的png文件,都将有一个 存储在Alpha通道中的透明度层遮罩。这使得 用于网站或游戏开发等的PNG文件。

您可以访问组成psp文件的块,或者 以编程方式,使用python api或通过命令行参数,以及 操作或保存到文件中。它们也可以转换为 枕头。图像对象,让你在它们上使用任何枕头功能, 包括以bmp/png以外的格式保存。

PaintShop Pro是一个全功能的图形编辑(光栅和矢量) Windows程序(仅限)。

枕头是一个用于处理图形的python包(这个库 利用)。

支持

  • 以psp x格式保存的文件(文件格式版本8)
    • 这是一个比最新销售的商业软件旧的版本, 因此,您需要使用file->;另存为
    • (请注意,这是我可以找到规范文档的最后一个版本 用于)
  • 以未压缩格式保存的层
    • 使用文件->;另存为,然后选择Uncompressed格式
    • 尚未支持RLE/LZ77格式,代码将引发异常- 在我的待办事项列表
    • 中固定这一点很高。
  • 光栅/遮罩/组类型的图层
    • 调整层等将被忽略,不会引发异常
  • 一组中的两层最大值(光栅+掩模)-添加更多的也是 在我的待办事项列表中
  • 保存PNG文件,将有一个透明层(alpha通道) 从psp文件的alpha通道抓取。
  • cli(命令行界面),用于文件操作/转换, 单独或按目录
  • 用于文件操作/转换的api命令
  • python 2.7版
  • 在Windows 7(Powershell)上测试,应适用于更高版本

PIP要求

  • 枕头>;=3.3.0
  • Virtualenv(可选,但强烈建议 虚拟说唱歌手)

Windows安装

windows-install 有关在本地安装程序的完整说明。

注意:如果您不关心虚拟环境,请从pypi安装 很简单:

pip install psp_scan

如果成功,python站点包目录位于任一路径中 或者Python,然后做:

python -m psp_scan -h

如果不起作用,请参见 windows-install 有关设置路径的详细信息。

cli和api

有两种方法可以使用包,一种是通过命令行 接口或python api。

cli更简单-运行psp_scan包,然后 各种参数,例如要转换的文件和格式, 它执行这个动作。但是,可用的cli参数有 只是api命令的一个子集。

api更复杂-您需要编写一个python程序 导入psp_scan包,并编写操作 根据需要保存图像,以及保存结果图像的其他函数。 但是,api中还有更多的特性,这些特性可能不是 可在cli中使用-因此如果您需要它们,就必须使用api。 特别是,枕头功能是可用的,例如,您可以 将图像旋转90度或缩放等。

cli用法

cli-docs 有关详细信息

cli用法和输出示例

Examples

cli命令列表

usage: psp_scan.py [-h] [-f {png,bmp}] [-m MASK] [-i DIR] [-o DIR] [-n] [-x] [-l] [-v] [-t] [file_in]

       psp_scan some_file.pspimage            # converts a single file to .png (default)
       psp_scan some_file.pspimage -m 3       # converts a single file to .png, and uses layer 3 mask in Alpha channel
       psp_scan some_file.pspimage -f bmp     # converts a single file to .bmp

       psp_scan -i some_dir -v                # converts all files (recursively) inside directory, prints output
       psp_scan -i some_dir -o new_dir        # converts all files (recursively) to new directory

       psp_scan -l some_file.pspimage         # lists basic block information for file (add -v for more detail)
       psp_scan -x some_file.pspimage         # expands file into blocks/layers, saves to new directory

positional arguments:
  file_in                           single file to convert (optional)

optional arguments:
  -h, --help                        show this help message and exit
  -f {png,bmp}, --format {png,bmp}  format to convert file into (optional, default=png)
  -m MASK, --mask MASK              mask-layer to use for PNG Alpha channel, for single file
  -i DIR, --input-dir DIR           directory to read files from (optional)
  -o DIR, --output-dir DIR          directory to save converted files (optional)
  -n, --non-recursive               read directories non-recursively (default is recursive)
  -x, --expand                      expand file into layers/blocks, save into directory
  -l, --list                        list basic block info (no file conversion) - add -v for more detail
  -v, --verbose                     extra output when processing files

API使用

api-docs 有关详细信息

API属性列表

- pic.doc
- pic.header            # returns a dict with selected data fields in PSP.info_chunk
- pic.header_full       # returns a dict with all data fields in PSP.info_chunk
- pic.filename          # returns the file used (as a string), or None if a file-pointer was passed in
- pic.width             # width/height for the entire image
- pic.height
- pic.blocks            # returns a list of blocks - the most important block, layers, has its own property
- pic.layers            # returns a list of layers
- pic.as_PIL            # returns a Pillow.Image object using the image's full bitmap (all layers combined)

- pic.layers[0].doc
- pic.layers[0].header  # returns a dict with all data fields in PSP.Layer.info_chunk
- pic.layers[0].name    # returns name of layer
- pic.layers[0].width   # width/height of the visible bitmap-rectangle in the Layer - note this
- pic.layers[0].height  # could be smaller than the image's width/height
- pic.layers[0].rect    # returns the rectangle (or bounding-box) that contains all the visible pixels for this layer
- pic.layers[0].as_PIL  # returns a Pillow.Image object using the layer's bitmap and width/height,
                        # or None if the layer doesn't have a bitmap (like a Group-layer) - check the return
- pic.layers[0].as_XL   # same as .as_PIL, but expands the layer to full image-size

api函数

pic.save_layers_to_file(tmp_dir)  # Saves Raster/Mask layers to separate bitmap files
pic.save_blocks_to_file(tmp_dir)  # Saves everything in all layers (channels, masks, etc) to bitmap files
pic.mask_to_alpha(7)              # returns a Pillow.Image object with an Alpha channel, from the selected mask

枕头功能

因为.as_PIL/.as_XL属性返回一个枕头.image对象, 你可以使用其中任何一个枕头功能。为了示例:

>>> foo = pic.layers[2].as_PIL
>>> foo.save('layer_three.bmp')
>>> flipped = foo.transpose(Image.ROTATE_90)
>>> flipped.save('layer_three_rot90.bmp')

这包括以其他格式保存-例如:

>>> foo.save('layer_three.tiff', format='tiff')

其他随机文档

部分学分

多亏了 LeviFiction 帮我解决一些文件格式问题。

PSP U扫描更改日志

0.9(2016-09-01)

  • 初始提交(John Crawford)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java异常无法从资源中找到可绘制的图标   Android 6.0.0上应用程序崩溃后java Android VM重新启动   当我将java项目导出到runnable jar中时,log4j不会记录日志   java在Jtable netbeans中显示MS访问数据   为什么不呢。Java中的NETstyle委托而不是闭包?   java如何正确使用如此多的CPU停止命令队列循环?   java使用==   java如何将scriptlet转换为JSTL?   java mvn测试失败,但通过IntelliJ IDEA运行测试   java为什么文件在使用另一个按钮后不会被删除   java JDBC MySQL不读取最新插入   java如何在安卓中绘制从Firebase数据库检索到的数据   java HTML解析getElementByClass方法   java Arraylist hashmap 安卓