Skip to content

Super-xBR pixel-art scaling algorithm ported to Python

License

Notifications You must be signed in to change notification settings

n0spaces/py-super-xbr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

py-super-xbr

The Super-xBR pixel-art scaling algorithm implemented as a Python module and command line tool.

Examples

Fawful (Mario & Luigi: Superstar Saga) scaled 2x (Image source)

Misery (Cave Story) scaled 4x (Image source)

Requirements

Python 3.6 or later. This was tested on Windows and Linux, but should also work on macOS.

Installation

This isn't uploaded to PyPI yet, so you'll have to build and install this from source.

  1. Clone this repository to your system
  2. Open a terminal and go to the repository's directory
  3. Run pip install .

Usage

From the command line

Applies the Super-xBR upscale filter to the image INPUT and saves it to OUTPUT:

superxbr [OPTIONS] INPUT OUTPUT
Options
positional arguments:
  INPUT       Input image file path
  OUTPUT      Output image file path

optional arguments:
  -h, --help  show this help message and exit
  -p PASSES   Number of times to apply the Super-xBR filter. The image
              scale is doubled each time the filter is applied. (default: 1)
  -m MODE     Color mode of the output image file. Choices are 1, L, LA, I, P,
              RGB, RGBA, or CMYK. Note that some color modes are not
              compatible with some image formats and will raise an exception.
              (default: RGBA)
  --quiet     Hide progress updates

In a Python script

Images are scaled using superxbr.scale()

from PIL import Image  # Pillow 7.x
from superxbr import superxbr

# Create an Image object
im = Image.open('example.png')

# Apply the Super-xBR scale filter to the image
im_scaled_2x = superxbr.scale(im)

# You can apply the filter multiple times
# The scale is doubled each time the filter is applied
im_scaled_8x = superxbr.scale(im, 3)

Building

Install required packages:

pip install -r requirements.txt

superxbr.c needs to be regenerated if superxbr.pyx is modified:

cython superxbr/superxbr.pyx

To compile a python extension module (.pyd or .so file):

python3 setup.py build_ext --inplace

To build a wheel:

python3 setup.py bdist_wheel

License

py-super-xbr is available under the MIT License. The code is based on the Super-xBR C++ port released by Hylian also under the MIT License.

See LICENSE.txt.

See also

About

Super-xBR pixel-art scaling algorithm ported to Python

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages