Skip to main content

Pixel art image scaling - Scale2x, Scale3x, Scale2xSFX and Scale3xSFX in pure Python

PyPI - Python Version PyPI - Version

Overview

ScaleNx, encompassing Scale2x, Scale3x, Scale2xSFX, and Scale3xSFX, is a group of pixel-art scaling algorithms, intended to rescale images without blurring sharp edges.

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.

Fig. 1. Example of consecutive upscaling with Scale3xSFX.
Consecutive upscaling with Scale3xSFX
Consecutive upscaling of tiny diagonal object with Scale3xSFX thrice. Source object on the left upscaled 3x3x3=27 times bigger in linear size, i.e. 27x27=729 times bigger by area, meaning that 728 out of 729 resulting pixels are purely artificial; yet the result looks surprisingly clear.

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. One of the advantages of these algorithms is that they don't use any empirical chroma mask or something else specifically adopted for game sprites on screen, and therefore are capable to work efficiently on any image, including images intended for print.

Fig. 2. Example of low resolution drawing upscaling with Scale3xSFX.
Upscaling with Scale3xSFX
Jagged lines of low resolution original are turned into smoother diagonals.

Unfortunately, while specialised Scale2x and Scale3x screen renderers (e.g. for DOS emulators) are numerous, it appears to be next to impossible to find ready-made batch processing application working with arbitrary images in common graphics formats.

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 omnicompatible.

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

python -m pip install --upgrade scalenx.

Usage

As of version 2026.2.12.34, recommended ScaleNx module usage is:

from scalenx import scaleNx
scaled_image = scaleNx(source_image, n, sfx)

where:

  • source_image is source image data as list[list[list[int]]];
  • int n value should be either 2 or 3, meaning the choice between Scale2* and Scale3* methods;
  • bool sfx means whether you choose ScaleNxSFX methods rather than classic ScaleNx;
  • scaled_image is resulting image data as list[list[list[int]]].

However, legacy module access (as of version 2024.11.24) still works, and for, say, Scale2x it looks like:

from scalenx import scalenx
scaled_image = scalenx.scale2x(source_image)

therefore no changes required for programs written using older (2024-2025) versions of ScaleNx.

Current Python 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 dead forum article, archived copy.

  3. Pixel-art scaling algorithms review at Wikipedia.

  4. Current ScaleNx implementation main page with some explanations and illustration.

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

  6. ScaleNx source code 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 2026.2.12.34

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 2026.2.12.34
File Size Uploaded Provenance Actions
scalenx-2026.2.12.34.tar.gz 9.3 kB Without provenance Details for scalenx-2026.2.12.34.tar.gz

Built distribution (wheel)

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

Total release size: 21.5 kB

Release files / scalenx-2026.2.12.34.tar.gz

Download URL scalenx-2026.2.12.34.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
46c85b0c7f389fd97e047f456b89b56385f4badaf2bed26cd893e395840d3fee
BLAKE2b-256 checksum
How to use checksums
6a43fb8159fb14df1ba0e1b89951507536edb0b393b5f42f4499ee87f063bc21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / scalenx-2026.2.12.34-py3-none-any.whl

Download URL scalenx-2026.2.12.34-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ea3b1149bc2be3c670e31981d1bf5ca1c8f9c1d8f1c2568859bade70af5faf2a
BLAKE2b-256 checksum
How to use checksums
5445352a50b06d6b06c4708071e6c7090a395dca6c152a384f0c3507d19be155
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Security for ScaleNx 2026.2.12.34

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