Skip to main content

Encoder and decoder for Aperture Science Image Format (apf), Aperture Science Image Format 2 (apf2), Wireless Bitmap (wbmp), and Over-The-Air Bitmap (otb)

Project description

A library for converting to and from Aperture Science apf files, the custom extended apf2s, and otb/wbmp images.

usage:

import apftool

apfString = apftool.encodeapf(pngObject) # turns image bytes object into apf string
pngObject = apftool.decodeapf(apfString) # turns apf string object into image bytes

funcs and features

encoders:

encodeapf(img: bytes, lineskip: int = 1, findbestlineskip: bool = False) takes image bytes and outputs apf string. lineskip is interleave value, findbestlineskip brute-forces different interleave values to the possible max of 199 and uses the smallest one.

encodeaf2(img: bytes, lineskip: int = 1, findbestlineskip: bool = False, legacy: bool = False, trans: bool = False, pal: int = 95) takes image bytes and outputs af2 string. lineskip is interleave value, findbestlineskip brute-forces different interleave values to the provided lineskip and uses the smallest one. legacy uses apf1-style 1 color data instead of a 95 color palette. trans enables/disables transparency, which overrides a color. pal allows you to manually force a smaller palette.

encodewbmp(img: Image) takes pil image object and outputs wbmp bytes

encodeotab(img: Image, width=255, height=255) takes pil image object and outputs otb bytes. max size is 255x255

decoders:

decodeany(data, format: str = 'PNG', returnImageObject: bool = False) takes in string or bytes and outputs bytes image or PIL image using best-guess for the decoders

decodeapf(apf: str, format: str = 'PNG', returnImageObject: bool = False) takes apf string and outputs either image bytes in specified format or pil image object

decodeaf2(af2: str, format: str = 'PNG', returnImageObject: bool = False) hi i am the same thing, i am literally a dropin replacement for decodeapf too

decodewbmp(wbmp: bytes, format: str = 'PNG', returnImageObject: bool = False) takes wbmp bytes and outputs either image bytes in specified format or pil image object

decodeotab(otab: bytes, format: str = 'PNG', returnImageObject: bool = False) hi i have the same usage as decodewbmp but for .otb images

dependancies

PIL, io, textwrap, math (apftool)

most of these a builtins but you may need to install PIL seperately

changelog:

0.4.0 - add support for otb images, improve readme.md, and add decodeany to decode all suported formats automatically

0.3.3 - make the af2 decoder more lenient

0.3.2 - i forgot but i think it made the af2 decoder more lenient

0.3.1 - fix 0.3.0

0.3.0 - add support for wbmp images, broken release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apftool-0.4.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apftool-0.4.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file apftool-0.4.0.tar.gz.

File metadata

  • Download URL: apftool-0.4.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for apftool-0.4.0.tar.gz
Algorithm Hash digest
SHA256 478a854a121b1c740ccfa4d38520ac35782b5b9310ea0f080311077f2fdd321f
MD5 1e260dbf596f018403a624ab46fecb0c
BLAKE2b-256 1ab5a3f334130aac695e0c5dabf7bf106c72eb97dba79db376852d23d2ef66ba

See more details on using hashes here.

File details

Details for the file apftool-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: apftool-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for apftool-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ef8152b85cd0a95b52dac3eb3c7f8fe8cfbe20806b4d9689dc68615e4e352cce
MD5 803bcdf7829d2534bee1c99e8110ac8f
BLAKE2b-256 8ed236b1eeb56126cc9854aea6a1f493610208416267ef90fff25082827c8025

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page