pypdn


Namepypdn JSON
Version 1.0.6 PyPI version JSON
download
home_pagehttps://github.com/addisonElliott/pypdn
SummaryPython package to read and write Paint.NET (PDN) images.
upload_time2021-01-20 03:53:20
maintainer
docs_urlNone
authorAddison Elliott
requires_python>=3.4
licenseMIT License
keywords paint dot net paintdotnet dotnet .net pdn library read write save layered images image editor
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
Introduction
=================
pypdn is a Python package for reading and writing Paint.NET (PDN) images.

"Paint.NET is image and photo editing software for PCs that run Windows. It features an intuitive and innovative user interface with support for layers, unlimited undo, special effects, and a wide variety of useful and powerful tools. An active and growing online community provides friendly help, tutorials, and plugins."

When using Paint.NET, the default file format that the images are saved in are PDN's, which is a proprietary format Paint.NET uses. The benefit of this format over BMP, PNG, JPEG, etc is that it stores layer information and properties that are not present in traditional image formats.

You can get Paint.NET `here <https://www.getpaint.net/>`_.

Paint.NET is developed using C# (hence the .NET). Besides a basic XML header at the beginning, it primarily uses the
BinaryFormatter class in C# to save the relevant classes when saving an image. This uses the `NRBF protocol
<https://msdn.microsoft.com/en-us/library/cc236844.aspx>`_. A custom reader was developed to read the NRBF file and
then this library essentially just parses the data from NRBF into more readable and user-friendly format. You can
access the NRBF reader from the pypdn module as well in case you have any use for it.

Installing
=================
Prerequisites
-------------
* Python 3.4+
* Dependencies:
    * numpy
    * aenum

Installing pypdn
-------------------------
pypdn is currently available on `PyPi <https://pypi.python.org/pypi/pypdn/>`_. The simplest way to
install alone is using ``pip`` at a command line::

  pip install pypdn

which installs the latest release.  To install the latest code from the repository (usually stable, but may have
undocumented changes or bugs)::

  pip install git+https://github.com/addisonElliott/pypdn.git


For developers, you can clone the pypdn repository and run the ``setup.py`` file. Use the following commands to get
a copy from GitHub and install all dependencies::

  git clone pip install git+https://github.com/addisonElliott/pypdn.git
  cd pypdn
  pip install .

or, for the last line, instead use::

  pip install -e .

to install in 'develop' or 'editable' mode, where changes can be made to the local working code and Python will use
the updated code.

Test and coverage
=================
To test the code on any platform, make sure to clone the GitHub repository to get the tests and run the following from
the repository directory::

  python -m unittest discover -v tests

Example
=================
For the below example, any PDN file will do. If you are looking for an example, check out the tests/data directory for
some!

.. code-block:: python

    import pypdn
    import matplotlib.pyplot as plt

    layeredImage = pypdn.read('Untitled3.pdn')
    print(layeredImage)
    # Contains width, height, version and layers of the image within the class
    # Version being the Paint.NET version that the image was saved with

    # Each layer contains the name, visibility boolean, opacity (0-255), isBackground and blendMode
    # From what I can tell, the isBackground property is not that useful
    # The blend mode is how the layer should be blended with the layers below it
    # These attributes are loaded from the PDN file but can be edited in the code as well
    print(layeredImage.layers)
    layer = layeredImage.layers[0]
    layer.visible = True
    layer.opacity = 255
    layer.blendMode = pypdn.BlendType.Normal

    layer = layeredImage.layers[1]
    layer.visible = True
    layer.opacity = 161
    layer.blendMode = pypdn.BlendType.Additive

    # Finally, the most useful thing is being able to combine the layers and flattn them into one image
    # Call the flatten function to do so
    # It will go through each layer and apply them IF the visibility is true!
    # The layer opacity and blend mode will be taken into effect
    #
    # The flattened image is a RGBA Numpy array image
    # The asByte parameter determines the data type of the flattened image
    # If asByte is True, then the dtype will be uint8, otherwise it will be a float in range (0.0, 1.0)
    flatImage = layeredImage.flatten(asByte=True)

    plt.figure()
    plt.imshow(flatImage)

    # Individual layer images can be retrieved as well
    # Note: This does NOT apply blending or the layer opacity
    # Rather, it is the image data that is saved by Paint.NET for the layer
    plt.figure()
    plt.imshow(layeredImage.layers[1].image)

    plt.show()

Using the Untitled3.pdn in the tests/data directory, this is the text output:

.. code-block::

    >>> print(layeredImage)
    pypdn.LayeredImage(width=800, height=600, version=System_Version(Major=4, Minor=21, Build=6589, Revision=7045), layers=[pypdn.Layer(name=Background, visible=True, isBackground=True, opacity=255, blendMode=<BlendType.Normal: 0>), pypdn.Layer(name=Layer 2, visible=True, isBackground=False, opacity=161, blendMode=<BlendType.Additive: 2>)])

    >>> print(layeredImage.layers)
    [pypdn.Layer(name=Background, visible=True, isBackground=True, opacity=255, blendMode=<BlendType.Normal: 0>), pypdn.Layer(name=Layer 2, visible=True, isBackground=False, opacity=161, blendMode=<BlendType.Additive: 2>)]

Roadmap & Bugs
=================
- Write docstrings and create basic documentation for NRBF and PDN classes
- Fix issue where _id and _classID are mixed up in NRBF reader
- Add support for writing NRBF files
- Write unit tests for NRBF
- Add support for writing PDN files (must complete writing NRBF files first)

Pull requests are welcome (and encouraged) for any or all issues!

License
=================
pypdn has an MIT-based `license <https://github.com/addisonElliott/pypdn/blob/master/LICENSE>`_.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/addisonElliott/pypdn",
    "name": "pypdn",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.4",
    "maintainer_email": "",
    "keywords": "paint dot net paintdotnet dotnet .net pdn library read write save layered images image editor",
    "author": "Addison Elliott",
    "author_email": "addison.elliott@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/02/43/0ebc35aacea20ff39edf517561361dd997b7e3a44f170372f4f8c0d263a4/pypdn-1.0.6.tar.gz",
    "platform": "",
    "description": "\nIntroduction\n=================\npypdn is a Python package for reading and writing Paint.NET (PDN) images.\n\n\"Paint.NET is image and photo editing software for PCs that run Windows. It features an intuitive and innovative user interface with support for layers, unlimited undo, special effects, and a wide variety of useful and powerful tools. An active and growing online community provides friendly help, tutorials, and plugins.\"\n\nWhen using Paint.NET, the default file format that the images are saved in are PDN's, which is a proprietary format Paint.NET uses. The benefit of this format over BMP, PNG, JPEG, etc is that it stores layer information and properties that are not present in traditional image formats.\n\nYou can get Paint.NET `here <https://www.getpaint.net/>`_.\n\nPaint.NET is developed using C# (hence the .NET). Besides a basic XML header at the beginning, it primarily uses the\nBinaryFormatter class in C# to save the relevant classes when saving an image. This uses the `NRBF protocol\n<https://msdn.microsoft.com/en-us/library/cc236844.aspx>`_. A custom reader was developed to read the NRBF file and\nthen this library essentially just parses the data from NRBF into more readable and user-friendly format. You can\naccess the NRBF reader from the pypdn module as well in case you have any use for it.\n\nInstalling\n=================\nPrerequisites\n-------------\n* Python 3.4+\n* Dependencies:\n    * numpy\n    * aenum\n\nInstalling pypdn\n-------------------------\npypdn is currently available on `PyPi <https://pypi.python.org/pypi/pypdn/>`_. The simplest way to\ninstall alone is using ``pip`` at a command line::\n\n  pip install pypdn\n\nwhich installs the latest release.  To install the latest code from the repository (usually stable, but may have\nundocumented changes or bugs)::\n\n  pip install git+https://github.com/addisonElliott/pypdn.git\n\n\nFor developers, you can clone the pypdn repository and run the ``setup.py`` file. Use the following commands to get\na copy from GitHub and install all dependencies::\n\n  git clone pip install git+https://github.com/addisonElliott/pypdn.git\n  cd pypdn\n  pip install .\n\nor, for the last line, instead use::\n\n  pip install -e .\n\nto install in 'develop' or 'editable' mode, where changes can be made to the local working code and Python will use\nthe updated code.\n\nTest and coverage\n=================\nTo test the code on any platform, make sure to clone the GitHub repository to get the tests and run the following from\nthe repository directory::\n\n  python -m unittest discover -v tests\n\nExample\n=================\nFor the below example, any PDN file will do. If you are looking for an example, check out the tests/data directory for\nsome!\n\n.. code-block:: python\n\n    import pypdn\n    import matplotlib.pyplot as plt\n\n    layeredImage = pypdn.read('Untitled3.pdn')\n    print(layeredImage)\n    # Contains width, height, version and layers of the image within the class\n    # Version being the Paint.NET version that the image was saved with\n\n    # Each layer contains the name, visibility boolean, opacity (0-255), isBackground and blendMode\n    # From what I can tell, the isBackground property is not that useful\n    # The blend mode is how the layer should be blended with the layers below it\n    # These attributes are loaded from the PDN file but can be edited in the code as well\n    print(layeredImage.layers)\n    layer = layeredImage.layers[0]\n    layer.visible = True\n    layer.opacity = 255\n    layer.blendMode = pypdn.BlendType.Normal\n\n    layer = layeredImage.layers[1]\n    layer.visible = True\n    layer.opacity = 161\n    layer.blendMode = pypdn.BlendType.Additive\n\n    # Finally, the most useful thing is being able to combine the layers and flattn them into one image\n    # Call the flatten function to do so\n    # It will go through each layer and apply them IF the visibility is true!\n    # The layer opacity and blend mode will be taken into effect\n    #\n    # The flattened image is a RGBA Numpy array image\n    # The asByte parameter determines the data type of the flattened image\n    # If asByte is True, then the dtype will be uint8, otherwise it will be a float in range (0.0, 1.0)\n    flatImage = layeredImage.flatten(asByte=True)\n\n    plt.figure()\n    plt.imshow(flatImage)\n\n    # Individual layer images can be retrieved as well\n    # Note: This does NOT apply blending or the layer opacity\n    # Rather, it is the image data that is saved by Paint.NET for the layer\n    plt.figure()\n    plt.imshow(layeredImage.layers[1].image)\n\n    plt.show()\n\nUsing the Untitled3.pdn in the tests/data directory, this is the text output:\n\n.. code-block::\n\n    >>> print(layeredImage)\n    pypdn.LayeredImage(width=800, height=600, version=System_Version(Major=4, Minor=21, Build=6589, Revision=7045), layers=[pypdn.Layer(name=Background, visible=True, isBackground=True, opacity=255, blendMode=<BlendType.Normal: 0>), pypdn.Layer(name=Layer 2, visible=True, isBackground=False, opacity=161, blendMode=<BlendType.Additive: 2>)])\n\n    >>> print(layeredImage.layers)\n    [pypdn.Layer(name=Background, visible=True, isBackground=True, opacity=255, blendMode=<BlendType.Normal: 0>), pypdn.Layer(name=Layer 2, visible=True, isBackground=False, opacity=161, blendMode=<BlendType.Additive: 2>)]\n\nRoadmap & Bugs\n=================\n- Write docstrings and create basic documentation for NRBF and PDN classes\n- Fix issue where _id and _classID are mixed up in NRBF reader\n- Add support for writing NRBF files\n- Write unit tests for NRBF\n- Add support for writing PDN files (must complete writing NRBF files first)\n\nPull requests are welcome (and encouraged) for any or all issues!\n\nLicense\n=================\npypdn has an MIT-based `license <https://github.com/addisonElliott/pypdn/blob/master/LICENSE>`_.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Python package to read and write Paint.NET (PDN) images.",
    "version": "1.0.6",
    "project_urls": {
        "Documentation": "https://github.com/addisonElliott/pypdn",
        "Homepage": "https://github.com/addisonElliott/pypdn",
        "Source": "https://github.com/addisonElliott/pypdn",
        "Tracker": "https://github.com/addisonElliott/pypdn/issues"
    },
    "split_keywords": [
        "paint",
        "dot",
        "net",
        "paintdotnet",
        "dotnet",
        ".net",
        "pdn",
        "library",
        "read",
        "write",
        "save",
        "layered",
        "images",
        "image",
        "editor"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aefddc130ac32e513e3faca797389e89b030c91d91dbf2f996964f58ca5d3352",
                "md5": "86603f19b249c940822183ab64448c81",
                "sha256": "88c7fcd6e17af58c44f9ae96177bbebf6a41c6f0ea2e27726b56560645144765"
            },
            "downloads": -1,
            "filename": "pypdn-1.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "86603f19b249c940822183ab64448c81",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.4",
            "size": 2114449,
            "upload_time": "2021-01-20T03:53:18",
            "upload_time_iso_8601": "2021-01-20T03:53:18.846577Z",
            "url": "https://files.pythonhosted.org/packages/ae/fd/dc130ac32e513e3faca797389e89b030c91d91dbf2f996964f58ca5d3352/pypdn-1.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "02430ebc35aacea20ff39edf517561361dd997b7e3a44f170372f4f8c0d263a4",
                "md5": "c83bb4ee97c4bf27b1d07500ec401190",
                "sha256": "92aba35a952884a05252426284782248971cde8f15f5d5d194043986f0185645"
            },
            "downloads": -1,
            "filename": "pypdn-1.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "c83bb4ee97c4bf27b1d07500ec401190",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.4",
            "size": 2113059,
            "upload_time": "2021-01-20T03:53:20",
            "upload_time_iso_8601": "2021-01-20T03:53:20.438210Z",
            "url": "https://files.pythonhosted.org/packages/02/43/0ebc35aacea20ff39edf517561361dd997b7e3a44f170372f4f8c0d263a4/pypdn-1.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-01-20 03:53:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "addisonElliott",
    "github_project": "pypdn",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pypdn"
}
        
Elapsed time: 0.21915s