Skip to main content

A small package to manage loading and saving SGF files

Project description

SGF Image Loader

A small package for loading and saving files in the SGF format. SGF stands for Simple Graphic Format, and it's a custom file format I designed to help me learn various different topics.

Limitations

SGF is primarily geared towards simpler pixel art images. Additionally, due to SGF's simple implementation, images are limited by two factors:

  1. SGF has a max palette size of 256 colors
  2. SGF has a max image size of 65,535 x 65,535 pixels

Usage

The SGF Image Loader requires a Pillow Image object for loading and saving files in the SGF format.

To store a Pillow Image:

from PIL import Image
from sgf_image_loader.sgf import SGF

# load image using Pillow
image = Image.open("file_name.png")

# save image in the SGF format
SGF.save_sgf("file_name.sgf", image, find_best=True)

Note: The find_best parameter causes the image loader to try every parameter combination to find the best possible parameters (more information below). This causes slower save times, but a generally smaller file.

In order to load an SGF image:

image = SGF.load_sgf("file_name.sgf")

assuming all previously imported packages were also imported.

Parameters

Vertical Stacking (bool): The SGF format combines similar pixels into one "chunk" that is made up of a repetition value, and a color index. By default, this chunk is created by scanning the pixels horizontally, combining any continuous pixels with the same color. Enabling vertical_stacking causes the chunk to be created by scanning pixels vertically.

Disable Repetition (bool): By default, the SGF format attempts to compress groups of similar pixels into a smaller chunk. However, sometimes this may end up making the file size larger. Enabling disable_repetition causes each pixel to be stores as just a color index, with no repetition value.

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

sgf_image_loader-1.0.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

sgf_image_loader-1.0.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file sgf_image_loader-1.0.1.tar.gz.

File metadata

  • Download URL: sgf_image_loader-1.0.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for sgf_image_loader-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c9c08d3fd001dd129af31e9d52425018dfad531631ca70ff2d10c3f031b4acfb
MD5 7f22a8d9fde805630c60cb84c92db991
BLAKE2b-256 5f18f816551d45ad64765059c19890414fd8c82836a90647822fd4b1dda3a9ca

See more details on using hashes here.

File details

Details for the file sgf_image_loader-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for sgf_image_loader-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a5d7317793c937d745f83cd1a42f42955224c41327f2955ab824fdc69c0811f0
MD5 f19206af0abc1fce70256b8071766a5f
BLAKE2b-256 240db32d43d9c97d3bddeab138e9f70f9334fa526c45acb87a2e7bebfaab0218

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