c64img


Namec64img JSON
Version 3.5 PyPI version JSON
download
home_pageNone
SummaryImage processing and converter for C64 graphic formats
upload_time2024-05-26 16:00:37
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseBSD
keywords c64 image converter koala art studio raw
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ======
C64img
======

C64img is a python package which provides an abstraction layer for creating
images which Commodore 64 understands. This is especially useful in converting
images created on PC graphics tools, with C64 limitation in mind.

This project was inspired by `PNG2HIRES_ v0.1 gfx format converter`_ /enthusi
(onslaught), which was initially used as simple graphics converter between
PNG/GIF images to C64 hires (Art studio + executable). It evolved to bunch of
modules, which have own purposes - from simply converting graphics, to
generating data for C64 programs written in cross compilers, or even generating
data for memory optimised animations out of sequence of images.

Image2c64
=========

Image2c64 is a frontend program to ``c64img`` module, which can converts
virtually any image supported by `Pillow`_ to C64 hires or multicolor formats.
Best results are achieved with filetypes PNG or GIF.

As an input 320x200 (multicolor or hires) or 160x200 (mutlicolor) picture is
expected. Mutlicolor pictures will be scaled down to 160x200. Picture will be
converted to 16 colors. During that process some information can be lost, if
used more than 16 colors.

Requirements:
-------------

+ `Python`_ >=3.8
+ `Pillow`_ >=10.3.0


Installation
------------

To install c64img you'll need `pip`_ tool. For installation system wide use
following command as a root (or by using i.e. sudo), assuming you're inside
cloned c64img repository:

.. code:: shell-session

   # pip install .

or, you can grab latest stable version from `pypi`_:

.. code:: shell-session

   # pip install c64img

Virtualenv also can be used, especially if you have no root access:

.. code:: shell-session

   $ virtualenv venvname
   $ source venvname/bin/activate
   (venvname) $ pip install c64img

After that, you should have ``image2c64`` executable available and be able to
import ``c64img`` module in Python interpreter.


Usage:
------

First of all, check up the switches program provides:

.. code:: shell-session

   $ image2c64 --help

Besides fine-tuning options like ``-b``/``--border`` for selecting border
color, ``-g``/``--background`` for selecting background color, it allows to
select appropriate output format:

- *multi* - for pure data located at ``$6000``
- *hires* - same, but for hires bitmap and colors (``$2000``)
- *koala* - multicolor bitmap in Koala format
- *art-studio-hires* - high resolution bitmap in Art Studio format (hires
  version)

Those formats should be passed using ``-f``/``--format`` parameter.

Furthermore two more switches can be used for output format:

- *raw* (``-r``, ``--raw``) - this will produce four files (*prefix* is
  obtained from the input image file name, or by using ``-o`` switch for
  output):

  - ``prefix_bg.raw`` 1-byte file with background color,
  - ``prefix_screen.raw`` - screen colors (usually placed at $0400),
  - ``prefix_color-ram.raw`` - additional 3rd color (supposed to be placed at
    ``$d800``)
  - and finally ``prefix_bitmap.raw`` - with bitmap matrix of the picture

- *executable* - produces *prg* which can be executed on emulator or real C64.
  Note, that this is just a image data and little displayer added to the image
  data.

For example:

+ Convert PNG image to koala with detailed log:

  .. code:: shell-session

     $ image2c64 -vv -f koala image.png

  Output will be written to ``image.prg``.

+ Convert GIF image to executable hires image, and write output to
  ``output.prg`` file:

  .. code:: shell-session

     $ image2c64 -f hires -x -o output.prg image.gif

+ Convert several images to raw data. Put the files in ``out`` directory:

  .. code:: shell-session

     $ image2c64 -f multi -r -o out image.png image1.gif image2.gif image3.gif

Parameter ``-v``/``-verbose`` can be use multiple times (effective, maximum
amount is double v) which increase verbosity of the output. Using
``-q``/``--quiet`` have opposite effect - it will suppress the output.

Color clashes
.............

Script can make several things in case of color clashes. In C64 graphics modes
you cannot put pixels in as one like, since there was hardware limitations
(memory, processing power etc), which provided to restrictions in graphics
modes. For example, in standard hires mode (320x200) it is impossible to use
more than 2 colors in 8x8 pixel area.

Underneath, c64img provides several options for color clash situation. By using
``-e``/``--errors`` switch with one of the following parameter, user can
influence conversion process in case of clashes/errors:

- no parameter or ``none`` - raport it on the console
- ``show`` - will display it - every wrong area will be marked with red
  rectangle
- ``save`` - will produce file with suffix ``_error.png`` next to original file
- ``grafx2`` - will save the error file, and open `grafx2`_ image editor with
  original image in front screen and error image on the spare screen. This is
  useful for manual clash corrections. Executable ``grafx2`` must be reachable
  by the environment variable ``PATH``.
- ``fix`` - will **try** to fix the clashes. Note, that this method is pretty
  naïve - the approximation of the colors is coarse, and may produce strange
  results.

Example of output for ``save`` and ``fix`` arguments for ``--error`` parameter:

.. code:: shell-session

   $ ./image2c64 -f multi -x -e save test_images/clash.multi.png
   ERROR: Too many colors per block in char 10, 11 near x=76, y=84.
   ERROR: Too many colors per block in char 11, 13 near x=84, y=100.
   ERROR: Too many colors per block in char 12, 15 near x=92, y=116
   $ ./image2c64 -f multi -x -e fix test_images/clash.multi.png
   WARNING: Cannot remap color; using background - 'Light green'
   $

Changes
-------

+ 2021-08-14 Forgot to push python3 support!
+ 2018-06-12 Added information about possibility to convert picture to chars
  (no conversion! Just an info in log!)
+ 2015-09-10 Rearranged repository into separate modules for maintainability
+ 2014-11-16 Added mechanism for automatic clashes fix
+ 2014-11-11 Fixed issue with color clash check in multicolor
+ 2014-11-11 Added ``grafx2`` option into error param. In such case image will
  be opened in `grafx2`_ program alongside with the error pic on spare screen.
+ 2014-02-09 Rewrite the core of the converter (introduced *char* abstraction),
  added ability to convert sequence of images.
+ 2012-11-20 Added executable output format for multicolor
+ 2012-11-19 Added multicolor support, changes to the docstrings
+ 2012-11-18 First public release

Licence
-------

This software is licensed under 3-clause BSD license. See LICENSE file for
details.


.. _PNG2HIRES_ v0.1 gfx format converter: https://onslaught.atlantis-prophecy.org/releases/productions/c64/p/300/png-hires-v-.
.. _pillow: https://github.com/python-imaging/Pillow
.. _grafx2: http://grafx2.chez.com
.. _python: https://www.python.org
.. _setuptools: https://pypi.python.org/pypi/setuptools
.. _pip: https://github.com/pypa/pip
.. _pypi: https://pypi.org

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "c64img",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "c64, image, converter, koala, Art Studio, raw",
    "author": null,
    "author_email": "Roman Dobosz <gryf73@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/6d/1b/b3fbd0b1dbf5b977609fc1e967ea1670273af99f44b995ef6af5b8ab525d/c64img-3.5.tar.gz",
    "platform": null,
    "description": "======\nC64img\n======\n\nC64img is a python package which provides an abstraction layer for creating\nimages which Commodore 64 understands. This is especially useful in converting\nimages created on PC graphics tools, with C64 limitation in mind.\n\nThis project was inspired by `PNG2HIRES_ v0.1 gfx format converter`_ /enthusi\n(onslaught), which was initially used as simple graphics converter between\nPNG/GIF images to C64 hires (Art studio + executable). It evolved to bunch of\nmodules, which have own purposes - from simply converting graphics, to\ngenerating data for C64 programs written in cross compilers, or even generating\ndata for memory optimised animations out of sequence of images.\n\nImage2c64\n=========\n\nImage2c64 is a frontend program to ``c64img`` module, which can converts\nvirtually any image supported by `Pillow`_ to C64 hires or multicolor formats.\nBest results are achieved with filetypes PNG or GIF.\n\nAs an input 320x200 (multicolor or hires) or 160x200 (mutlicolor) picture is\nexpected. Mutlicolor pictures will be scaled down to 160x200. Picture will be\nconverted to 16 colors. During that process some information can be lost, if\nused more than 16 colors.\n\nRequirements:\n-------------\n\n+ `Python`_ >=3.8\n+ `Pillow`_ >=10.3.0\n\n\nInstallation\n------------\n\nTo install c64img you'll need `pip`_ tool. For installation system wide use\nfollowing command as a root (or by using i.e. sudo), assuming you're inside\ncloned c64img repository:\n\n.. code:: shell-session\n\n   # pip install .\n\nor, you can grab latest stable version from `pypi`_:\n\n.. code:: shell-session\n\n   # pip install c64img\n\nVirtualenv also can be used, especially if you have no root access:\n\n.. code:: shell-session\n\n   $ virtualenv venvname\n   $ source venvname/bin/activate\n   (venvname) $ pip install c64img\n\nAfter that, you should have ``image2c64`` executable available and be able to\nimport ``c64img`` module in Python interpreter.\n\n\nUsage:\n------\n\nFirst of all, check up the switches program provides:\n\n.. code:: shell-session\n\n   $ image2c64 --help\n\nBesides fine-tuning options like ``-b``/``--border`` for selecting border\ncolor, ``-g``/``--background`` for selecting background color, it allows to\nselect appropriate output format:\n\n- *multi* - for pure data located at ``$6000``\n- *hires* - same, but for hires bitmap and colors (``$2000``)\n- *koala* - multicolor bitmap in Koala format\n- *art-studio-hires* - high resolution bitmap in Art Studio format (hires\n  version)\n\nThose formats should be passed using ``-f``/``--format`` parameter.\n\nFurthermore two more switches can be used for output format:\n\n- *raw* (``-r``, ``--raw``) - this will produce four files (*prefix* is\n  obtained from the input image file name, or by using ``-o`` switch for\n  output):\n\n  - ``prefix_bg.raw`` 1-byte file with background color,\n  - ``prefix_screen.raw`` - screen colors (usually placed at $0400),\n  - ``prefix_color-ram.raw`` - additional 3rd color (supposed to be placed at\n    ``$d800``)\n  - and finally ``prefix_bitmap.raw`` - with bitmap matrix of the picture\n\n- *executable* - produces *prg* which can be executed on emulator or real C64.\n  Note, that this is just a image data and little displayer added to the image\n  data.\n\nFor example:\n\n+ Convert PNG image to koala with detailed log:\n\n  .. code:: shell-session\n\n     $ image2c64 -vv -f koala image.png\n\n  Output will be written to ``image.prg``.\n\n+ Convert GIF image to executable hires image, and write output to\n  ``output.prg`` file:\n\n  .. code:: shell-session\n\n     $ image2c64 -f hires -x -o output.prg image.gif\n\n+ Convert several images to raw data. Put the files in ``out`` directory:\n\n  .. code:: shell-session\n\n     $ image2c64 -f multi -r -o out image.png image1.gif image2.gif image3.gif\n\nParameter ``-v``/``-verbose`` can be use multiple times (effective, maximum\namount is double v) which increase verbosity of the output. Using\n``-q``/``--quiet`` have opposite effect - it will suppress the output.\n\nColor clashes\n.............\n\nScript can make several things in case of color clashes. In C64 graphics modes\nyou cannot put pixels in as one like, since there was hardware limitations\n(memory, processing power etc), which provided to restrictions in graphics\nmodes. For example, in standard hires mode (320x200) it is impossible to use\nmore than 2 colors in 8x8 pixel area.\n\nUnderneath, c64img provides several options for color clash situation. By using\n``-e``/``--errors`` switch with one of the following parameter, user can\ninfluence conversion process in case of clashes/errors:\n\n- no parameter or ``none`` - raport it on the console\n- ``show`` - will display it - every wrong area will be marked with red\n  rectangle\n- ``save`` - will produce file with suffix ``_error.png`` next to original file\n- ``grafx2`` - will save the error file, and open `grafx2`_ image editor with\n  original image in front screen and error image on the spare screen. This is\n  useful for manual clash corrections. Executable ``grafx2`` must be reachable\n  by the environment variable ``PATH``.\n- ``fix`` - will **try** to fix the clashes. Note, that this method is pretty\n  na\u00efve - the approximation of the colors is coarse, and may produce strange\n  results.\n\nExample of output for ``save`` and ``fix`` arguments for ``--error`` parameter:\n\n.. code:: shell-session\n\n   $ ./image2c64 -f multi -x -e save test_images/clash.multi.png\n   ERROR: Too many colors per block in char 10, 11 near x=76, y=84.\n   ERROR: Too many colors per block in char 11, 13 near x=84, y=100.\n   ERROR: Too many colors per block in char 12, 15 near x=92, y=116\n   $ ./image2c64 -f multi -x -e fix test_images/clash.multi.png\n   WARNING: Cannot remap color; using background - 'Light green'\n   $\n\nChanges\n-------\n\n+ 2021-08-14 Forgot to push python3 support!\n+ 2018-06-12 Added information about possibility to convert picture to chars\n  (no conversion! Just an info in log!)\n+ 2015-09-10 Rearranged repository into separate modules for maintainability\n+ 2014-11-16 Added mechanism for automatic clashes fix\n+ 2014-11-11 Fixed issue with color clash check in multicolor\n+ 2014-11-11 Added ``grafx2`` option into error param. In such case image will\n  be opened in `grafx2`_ program alongside with the error pic on spare screen.\n+ 2014-02-09 Rewrite the core of the converter (introduced *char* abstraction),\n  added ability to convert sequence of images.\n+ 2012-11-20 Added executable output format for multicolor\n+ 2012-11-19 Added multicolor support, changes to the docstrings\n+ 2012-11-18 First public release\n\nLicence\n-------\n\nThis software is licensed under 3-clause BSD license. See LICENSE file for\ndetails.\n\n\n.. _PNG2HIRES_ v0.1 gfx format converter: https://onslaught.atlantis-prophecy.org/releases/productions/c64/p/300/png-hires-v-.\n.. _pillow: https://github.com/python-imaging/Pillow\n.. _grafx2: http://grafx2.chez.com\n.. _python: https://www.python.org\n.. _setuptools: https://pypi.python.org/pypi/setuptools\n.. _pip: https://github.com/pypa/pip\n.. _pypi: https://pypi.org\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Image processing and converter for C64 graphic formats",
    "version": "3.5",
    "project_urls": {
        "Homepage": "https://bitbucket.org/gryf/image2c64"
    },
    "split_keywords": [
        "c64",
        " image",
        " converter",
        " koala",
        " art studio",
        " raw"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3e61137dac0cfb8790594c23f859122f9860feefc19c8f8482525e41950cce64",
                "md5": "1fd53d68535bf35125fb3f64795bc276",
                "sha256": "11839ecc6a515982b950a1b7c1d1fc912eb1b89338666bc1e92370fc67d489db"
            },
            "downloads": -1,
            "filename": "c64img-3.5-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1fd53d68535bf35125fb3f64795bc276",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.8",
            "size": 18860,
            "upload_time": "2024-05-26T16:00:35",
            "upload_time_iso_8601": "2024-05-26T16:00:35.849238Z",
            "url": "https://files.pythonhosted.org/packages/3e/61/137dac0cfb8790594c23f859122f9860feefc19c8f8482525e41950cce64/c64img-3.5-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6d1bb3fbd0b1dbf5b977609fc1e967ea1670273af99f44b995ef6af5b8ab525d",
                "md5": "9fdfc8267cee1887be5586b1aa1ac7f2",
                "sha256": "0976cf7665d2890d9f8fb8bf9fcb91188a5ac9bbf8ea14e82d54a522adda564e"
            },
            "downloads": -1,
            "filename": "c64img-3.5.tar.gz",
            "has_sig": false,
            "md5_digest": "9fdfc8267cee1887be5586b1aa1ac7f2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 27006,
            "upload_time": "2024-05-26T16:00:37",
            "upload_time_iso_8601": "2024-05-26T16:00:37.248794Z",
            "url": "https://files.pythonhosted.org/packages/6d/1b/b3fbd0b1dbf5b977609fc1e967ea1670273af99f44b995ef6af5b8ab525d/c64img-3.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-26 16:00:37",
    "github": false,
    "gitlab": false,
    "bitbucket": true,
    "codeberg": false,
    "bitbucket_user": "gryf",
    "bitbucket_project": "image2c64",
    "lcname": "c64img"
}
        
Elapsed time: 0.88384s