Skip to main content

Pixel Art Scaling - Scale2x, Scale3x, Scale2xSFX and Scale3xSFX in pure Python

PyPI - Python Version PyPI - Version

Overview

Scale2x and Scale3x (aka AdvMAME2x and AdvMAME3x) algorithms were developed by Andrea Mazzoleni for the sole purpose of scaling up small graphics like icons and game sprites while keeping sharp edges and avoiding blurs.

Later on versions called Scale2xSFX and Scale3xSFX were introduced for the same purpose, providing better diagonals rendering and less artifacts on some patterns.

Being initially created for tiny game sprite images, these algorithms appeared to be useful for some completely different tasks, e.g. scaling up text scans with low resolution before OCR, to improve OCR quality, or upscaling old low quality gravure and line art prints. Unfortunately, it appears to be next to impossible to find ready-made batch processor for working with arbitrary images.

Therefore, current general purpose pure Python implementation of algorithms above was developed. Current implementation does not use any import, neither Python standard nor third party, and therefore is quite cross-platform and next to onmicompatible.

Note that current PyPI-distributed package is intended for developers, and therefore include ScaleNx core module only. For example of practical Python program utilizing this module, with Tkinter GUI, multiprocessing etc., please visit ScaleNx at Github (PNG support in this program is based on PyPNG, and PPM and PGM support - on PyPNM, both of the above being pure Python modules as well).

Python compatibility

Current ScaleNx version is maximal backward compatibility build, created for PyPI distribution. While most of the development was performed using Python 3.12, testing with other versions was carried out, and ScaleNx proven to work with antique Python 3.4 under Windows XP 32-bit.

Installation

pip install ScaleNx, then from scalenx import scalenx, scalenxsfx.

Usage

Example for Scale3xSFX:

scaled_image = scalenxsfx.scale3x(source_image)

where both images are of 3D nested list (image) of lists (rows) of lists (pixels) of int (channel values) type.

Note that functions names in scalenx and scalenxsfx match, making it easy to switch external software from older scalenx to scalenxsfx or vs. by changing one import line. When creating new software, one may easily make it reconfigurable with reassigning functions names, like

if use_sfx:
    chosen_scaler = scalenxsfx.scale2x
else:
    chosen_scaler = scalenx.scale2x

scaled_image = chosen_scaler(source_image)

Current implementation was written by Ilya Razmanov and may be freely used, copied and improved. In case of making substantial improvements it's almost obligatory to share your work with the developer and lesser species.

References

  1. Scale2x and Scale3x algorithms description by the inventor, Andrea Mazzoleni.

  2. Scale2xSFX and Scale3xSFX algorithms description at forums archive.

  3. Pixel-art scaling algorithms review at Wikipedia.

  4. ScaleNx at Github - current ScaleNx source at Github, containing main program for single and batch image processing, with GUI, multiprocessing etc..

  5. ScaleNx for Python 3.4 at Github - same as above, but fully compatible with Python 3.4 (both ScaleNx and image formats I/O and main application).

Metadata

Release files for ScaleNx 2025.3.34.post1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ScaleNx 2025.3.34.post1
File Size Uploaded Provenance Actions
scalenx-2025.3.34.post1.tar.gz 7.5 kB Without provenance Details for scalenx-2025.3.34.post1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ScaleNx 2025.3.34.post1
File Interpreter ABI Platform Actions
scalenx-2025.3.34.post1-py3-none-any.whl Python 3 none any Details for scalenx-2025.3.34.post1-py3-none-any.whl

Total release size: 17.2 kB

Release files / scalenx-2025.3.34.post1.tar.gz

Download URL scalenx-2025.3.34.post1.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
dbb99443c40141e5511d84c0bad409404214090894b9a48763fe9f665bbb4e82
BLAKE2b-256 checksum
How to use checksums
e1f4a0fdcba3b74703c3592511d62122b3a3feead1a8d299d529443d80fbd89b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / scalenx-2025.3.34.post1-py3-none-any.whl

Download URL scalenx-2025.3.34.post1-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0383f08203411b4d9601068333f78a30358d147bdc5f6c1e5e40d26c0dfcf2a3
BLAKE2b-256 checksum
How to use checksums
b6889c2940655a5bfa70abec196edac5118eb34e45c2119e862b3d6c7159e8e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Security for ScaleNx 2025.3.34.post1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page