ScaleNx


NameScaleNx JSON
Version 2025.7.34 PyPI version JSON
download
home_pagehttps://dnyarri.github.io/
SummaryImage resizing using Scale2x, Scale3x, Scale2xSFX and Scale3xSFX algorithms, in pure Python.
upload_time2025-07-12 06:02:41
maintainerNone
docs_urlNone
authorIlya Razmanov
requires_python>=3.4
licenseNone
keywords scale2x scale3x scale2xsfx scale3xsfx advmame2 advmame3 pixel resize rescale image bitmap python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Pixel Art Scaling - Scale2x, Scale3x, Scale2xSFX and Scale3xSFX in pure Python

![PyPI - Python Version](https://img.shields.io/pypi/pyversions/scalenx) ![PyPI - Version](https://img.shields.io/pypi/v/scalenx)

## Overview

[**Scale2x** and **Scale3x**](https://github.com/amadvance/scale2x) (aka **AdvMAME2x** and **AdvMAME3x**) algorithms were developed by [Andrea Mazzoleni](https://www.scale2x.it/) 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**](https://web.archive.org/web/20160527015550/https://libretro.com/forums/archive/index.php?t-1655.html) 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](https://dnyarri.github.io/imgscalenx/diag3sfx.png "Consecutive upscaling with Scale3xSFX thrice") |
| *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](https://dnyarri.github.io/imgscalenx/mu3sfx.png "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](https://github.com/Dnyarri/PixelArtScaling) (PNG support in this program is based on [PyPNG](https://gitlab.com/drj11/pypng), and PPM and PGM support - on [PyPNM](https://pypi.org/project/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`, 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)

## Copyright and redistribution

Current Python implementation was written by [Ilya Razmanov](https://dnyarri.github.io/) 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](https://www.scale2x.it/algorithm) by the inventor, Andrea Mazzoleni.

2. [Scale2xSFX and Scale3xSFX algorithms description](https://web.archive.org/web/20160527015550/https://libretro.com/forums/archive/index.php?t-1655.html) at forums archive.

3. [Pixel-art scaling algorithms review](https://en.wikipedia.org/wiki/Pixel-art_scaling_algorithms) at Wikipedia.

4. [ScaleNx source code at Github](https://github.com/Dnyarri/PixelArtScaling/) - current ScaleNx source at Github, containing main program for single and batch image processing, with GUI, multiprocessing *etc.*.

5. [ScaleNx source code for Python 3.4 at Github](https://github.com/Dnyarri/PixelArtScaling/tree/py34) - same as above, but fully compatible with Python 3.4 (both ScaleNx and image formats I/O and main application).

            

Raw data

            {
    "_id": null,
    "home_page": "https://dnyarri.github.io/",
    "name": "ScaleNx",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.4",
    "maintainer_email": null,
    "keywords": "Scale2x, Scale3x, Scale2xSFX, Scale3xSFX, AdvMAME2, AdvMAME3, pixel, resize, rescale, image, bitmap, python",
    "author": "Ilya Razmanov",
    "author_email": "ilyarazmanov@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9b/19/0cad64a481afd39065a3fb24dcdb354161f96b485e1d94daf7b3feccb328/scalenx-2025.7.34.tar.gz",
    "platform": null,
    "description": "# Pixel Art Scaling - Scale2x, Scale3x, Scale2xSFX and Scale3xSFX in pure Python\r\n\r\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/scalenx) ![PyPI - Version](https://img.shields.io/pypi/v/scalenx)\r\n\r\n## Overview\r\n\r\n[**Scale2x** and **Scale3x**](https://github.com/amadvance/scale2x) (aka **AdvMAME2x** and **AdvMAME3x**) algorithms were developed by [Andrea Mazzoleni](https://www.scale2x.it/) for the sole purpose of scaling up small graphics like icons and game sprites while keeping sharp edges and avoiding blurs.\r\n\r\nLater on versions called [**Scale2xSFX** and **Scale3xSFX**](https://web.archive.org/web/20160527015550/https://libretro.com/forums/archive/index.php?t-1655.html) were introduced for the same purpose, providing better diagonals rendering and less artifacts on some patterns.\r\n\r\n| Fig. 1. *Example of consecutive upscaling with Scale3xSFX.* |\r\n| :---: |\r\n| ![Consecutive upscaling with Scale3xSFX](https://dnyarri.github.io/imgscalenx/diag3sfx.png \"Consecutive upscaling with Scale3xSFX thrice\") |\r\n| *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.* |\r\n\r\nBeing 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.\r\n\r\n| Fig. 2. *Example of low resolution drawing upscaling with Scale3xSFX.* |\r\n| :---: |\r\n| ![Upscaling with Scale3xSFX](https://dnyarri.github.io/imgscalenx/mu3sfx.png \"Upscaling with Scale3xSFX\") |\r\n| *Jagged lines of low resolution original are turned into smoother diagonals.* |\r\n\r\nUnfortunately, 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.\r\n\r\nTherefore, 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.\r\n\r\nNote 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](https://github.com/Dnyarri/PixelArtScaling) (PNG support in this program is based on [PyPNG](https://gitlab.com/drj11/pypng), and PPM and PGM support - on [PyPNM](https://pypi.org/project/PyPNM/), both of the above being pure Python modules as well).\r\n\r\n## Python compatibility\r\n\r\nCurrent 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.\r\n\r\n## Installation\r\n\r\n`python -m pip install --upgrade scalenx`, then `from scalenx import scalenx, scalenxsfx`.\r\n\r\n## Usage\r\n\r\nExample for Scale3xSFX:\r\n\r\n    scaled_image = scalenxsfx.scale3x(source_image)\r\n\r\nwhere both images are of 3D nested list (image) of lists (rows) of lists (pixels) of int (channel values) type.\r\n\r\nNote 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\r\n\r\n    if use_sfx:\r\n        chosen_scaler = scalenxsfx.scale2x\r\n    else:\r\n        chosen_scaler = scalenx.scale2x\r\n\r\n    scaled_image = chosen_scaler(source_image)\r\n\r\n## Copyright and redistribution\r\n\r\nCurrent Python implementation was written by [Ilya Razmanov](https://dnyarri.github.io/) 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.\r\n\r\n## References\r\n\r\n1. [Scale2x and Scale3x algorithms description](https://www.scale2x.it/algorithm) by the inventor, Andrea Mazzoleni.\r\n\r\n2. [Scale2xSFX and Scale3xSFX algorithms description](https://web.archive.org/web/20160527015550/https://libretro.com/forums/archive/index.php?t-1655.html) at forums archive.\r\n\r\n3. [Pixel-art scaling algorithms review](https://en.wikipedia.org/wiki/Pixel-art_scaling_algorithms) at Wikipedia.\r\n\r\n4. [ScaleNx source code at Github](https://github.com/Dnyarri/PixelArtScaling/) - current ScaleNx source at Github, containing main program for single and batch image processing, with GUI, multiprocessing *etc.*.\r\n\r\n5. [ScaleNx source code for Python 3.4 at Github](https://github.com/Dnyarri/PixelArtScaling/tree/py34) - same as above, but fully compatible with Python 3.4 (both ScaleNx and image formats I/O and main application).\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Image resizing using Scale2x, Scale3x, Scale2xSFX and Scale3xSFX algorithms, in pure Python.",
    "version": "2025.7.34",
    "project_urls": {
        "Changelog": "https://github.com/Dnyarri/PixelArtScaling/blob/py34/CHANGELOG.md",
        "Homepage": "https://dnyarri.github.io/",
        "Issues": "https://github.com/Dnyarri/PixelArtScaling/issues",
        "Source": "https://github.com/Dnyarri/PixelArtScaling"
    },
    "split_keywords": [
        "scale2x",
        " scale3x",
        " scale2xsfx",
        " scale3xsfx",
        " advmame2",
        " advmame3",
        " pixel",
        " resize",
        " rescale",
        " image",
        " bitmap",
        " python"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "bc08b6859f365eaaebfe307aae5ca4265fc2a6606731d8e3861635c3c71be1ad",
                "md5": "9e93e425bed4e3a07414bbc609284060",
                "sha256": "646f0187b4ca666bad0fdc95f52a25ff88fdf613e942ee6e203cda9466868980"
            },
            "downloads": -1,
            "filename": "scalenx-2025.7.34-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9e93e425bed4e3a07414bbc609284060",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.4",
            "size": 9527,
            "upload_time": "2025-07-12T06:02:40",
            "upload_time_iso_8601": "2025-07-12T06:02:40.186553Z",
            "url": "https://files.pythonhosted.org/packages/bc/08/b6859f365eaaebfe307aae5ca4265fc2a6606731d8e3861635c3c71be1ad/scalenx-2025.7.34-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "9b190cad64a481afd39065a3fb24dcdb354161f96b485e1d94daf7b3feccb328",
                "md5": "82ecc0a7a0de29561c2cbd6a3d05261a",
                "sha256": "fb81a760495488a26e057aad49c200233e6749d67ae6befd9265390454618398"
            },
            "downloads": -1,
            "filename": "scalenx-2025.7.34.tar.gz",
            "has_sig": false,
            "md5_digest": "82ecc0a7a0de29561c2cbd6a3d05261a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.4",
            "size": 7694,
            "upload_time": "2025-07-12T06:02:41",
            "upload_time_iso_8601": "2025-07-12T06:02:41.381420Z",
            "url": "https://files.pythonhosted.org/packages/9b/19/0cad64a481afd39065a3fb24dcdb354161f96b485e1d94daf7b3feccb328/scalenx-2025.7.34.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-12 06:02:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Dnyarri",
    "github_project": "PixelArtScaling",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "scalenx"
}
        
Elapsed time: 1.47118s