Coder Social home page Coder Social logo

py-super-xbr's Introduction

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

py-super-xbr's People

Contributors

n0spaces avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

py-super-xbr's Issues

3.11

Can't install this on 3.11

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.