Skip to main content

Binary Python3 bindings for the G'MIC C++ image processing library

Project description

G'MIC Logo Python Logo

Python binding for G'MIC - A Full-Featured Open-Source Framework for Image Processing

https://gmic.eu

gmic-py

The aim of this project is to provide an official Python 3 package of the G'MIC image processing library, with its platform-specific binaries bundled or auto-compiled. When this matures, running pip install gmic-py should be all you need to get ready and use G'MIC within data-science, games, video editing, texture editing etc.. Python scripts.

This project is a work in progress and lives under the CeCILL license (similar to GNU Public License).

Official platform support

You can build your own Gmic python binding on possibly any platform with a C/C++ compiler. Here is what we have managed to build and ship to Gmic PyPI page, allowing you to pip install gmic and use pre-built binaries or build gmic-py on the fly. Note that gmic-py's package installer links to your machine's existing libpng, OpenMP and libcURL if found.

Build target Basic gmic-py0 libpng I/O OpenMP libcURL OpenCV
Build from source1 2 2 2
DIY Linux 32&64bit 1 2 2 2
Pre-compiled Linux i686 & x86_64 py3.4-3.8 (gcc)m 3
Pre-compiled MacOS 64 py3.5-3.8 (clang)
Windows (unplanned)w

0 ie. gmic.GmicImage(bytes, w, h, d, s), gmic.run(..., "commands")

1 ie. from this project's tarball or using pip install gmic with the (possibly default) "from source" option. Hack the setup.py if needed, should work well with just libz installed, preferably with libfftw3 too to support all sizes of images. Compiling with gcc or clang should work well.

2 enabled if related library is found at compile time, using found pkg-config executable.

3 useful for samples retrieval and getting the latest filters collection updated; instead of linking against libcURL, any runtime-findable curl executable will be used, see this issue; at anytime, use the network 0 G'MIC command to disable internet access

m those are actually manylinux2010 and manylinux2014 targets. Manylinux1 has been dropped

w you can try building you own gmic-py builds on Windows using MSYS2

Examples

Using your camera with G'MIC's optional OpenCV linking

If your machine has libopencv installed and your gmic-py was compiled from source (ie. python setup.py build), it will be dynamically linked.

Example script

Live example

Roadmap

Q4 2019

  1. Create a pip install -e GITHUB_URL installable Python package for GMIC, with an API very similar to the C++ library: gmic_instance.run(...), gmic(...) and matching exception types. Binary dependencies should be bundled as in this tutorial.
    1. Through Ctypes dynamic binding on an Ubuntu docker image using Python 2-3. DONE in ctypes/
    2. Through custom Python/C++ binding in cpython/ WIP
  2. Create documented examples for various application domains. WIP

Q1-Q2 2020

  1. Move the package to official Python package repositories.
  2. In a separate repository, create a Blender Plugin, leveraging the Python library and exposing:
  3. a single Blender GMIC 2D node with a text field or linkable script to add a GMIC expression
  4. as many 2D nodes as there are types of GMIC 'operators'

Q3-Q4 2020

  1. In a separate repository, create a GMIC Inkscape plugin, leveraging the Python library (possibly applying only to image objects, as the Trace bitmap tool does).

Binding blueprint

This is an overview of how we want the gmic binding inner working:

from gmic import Gmic, run, Image, GmicException
#we give up the Gmic native List

class GmicException:
   def __init__(self, command, message):
       self.command = command
       self.message = message
   def what(self):
       pass
   def command_help(self):
       pass

class Gmic:
    def __init__(self, images=[]|tuple|iterable[Image], image_names=[]|tuple|iterable, include_stdlib=True, progress=None, is_abort=None):
        self._status = None
        self.include_stdlib = include_stdlib
        # TODO V2 = progress, is_abort
        if all params were given:
           self.run(images, image_names, include_stdlib, progress, is_abort)

    @throws GmicException
    def run(self, images=[], images_names=[], progress=None, abort=None):
        ....
        self._status = ""
        return self

    def _build_lists(self):
        self._build_gmic_images_list(self.images)
        self._build_gmic_images_names_list(self.image_names)

    def _build_gmic_images_list(self):
        """Convert and store to Gmic builtin C++ type"""
        pass

    def _build_gmic_images_names_list(self):
        """Convert and store to Gmic builtin C++ type"""
        pass

    @property
    def status(self):
       """ string result of last operation, or exception text if was raised, or user-entered text through a gmic command. 
       This is a read-only attribute, starting with underscore. See https://stackoverflow.com/a/15812738/420684
       :return str
       """
       return self._status


def run(images=[]|tuple|iterable[Image], image_names=[]|tuple|iterable[Image], include_stdlib=True, progress=None, is_abort=None):
    return Gmic(images, images_names, include_stdlib, progress, is_abort).run()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gmic-2.8.1.dev7.tar.gz (1.4 MB view hashes)

Uploaded Source

Built Distributions

gmic-2.8.1.dev7-cp38-cp38-manylinux2014_x86_64.whl (5.3 MB view hashes)

Uploaded CPython 3.8

gmic-2.8.1.dev7-cp38-cp38-manylinux2014_i686.whl (4.9 MB view hashes)

Uploaded CPython 3.8

gmic-2.8.1.dev7-cp38-cp38-manylinux2010_x86_64.whl (5.1 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

gmic-2.8.1.dev7-cp38-cp38-manylinux2010_i686.whl (4.7 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

gmic-2.8.1.dev7-cp38-cp38-macosx_10_10_x86_64.whl (3.6 MB view hashes)

Uploaded CPython 3.8 macOS 10.10+ x86-64

gmic-2.8.1.dev7-cp37-cp37m-manylinux2014_x86_64.whl (5.3 MB view hashes)

Uploaded CPython 3.7m

gmic-2.8.1.dev7-cp37-cp37m-manylinux2014_i686.whl (4.9 MB view hashes)

Uploaded CPython 3.7m

gmic-2.8.1.dev7-cp37-cp37m-manylinux2010_x86_64.whl (5.1 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

gmic-2.8.1.dev7-cp37-cp37m-manylinux2010_i686.whl (4.7 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

gmic-2.8.1.dev7-cp37-cp37m-macosx_10_10_intel.whl (7.3 MB view hashes)

Uploaded CPython 3.7m macOS 10.10+ intel

gmic-2.8.1.dev7-cp36-cp36m-manylinux2014_x86_64.whl (5.3 MB view hashes)

Uploaded CPython 3.6m

gmic-2.8.1.dev7-cp36-cp36m-manylinux2014_i686.whl (4.9 MB view hashes)

Uploaded CPython 3.6m

gmic-2.8.1.dev7-cp36-cp36m-manylinux2010_x86_64.whl (5.1 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

gmic-2.8.1.dev7-cp36-cp36m-manylinux2010_i686.whl (4.7 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ i686

gmic-2.8.1.dev7-cp36-cp36m-macosx_10_10_intel.whl (7.3 MB view hashes)

Uploaded CPython 3.6m macOS 10.10+ intel

gmic-2.8.1.dev7-cp35-cp35m-manylinux2014_x86_64.whl (5.3 MB view hashes)

Uploaded CPython 3.5m

gmic-2.8.1.dev7-cp35-cp35m-manylinux2014_i686.whl (4.9 MB view hashes)

Uploaded CPython 3.5m

gmic-2.8.1.dev7-cp35-cp35m-manylinux2010_x86_64.whl (5.1 MB view hashes)

Uploaded CPython 3.5m manylinux: glibc 2.12+ x86-64

gmic-2.8.1.dev7-cp35-cp35m-manylinux2010_i686.whl (4.7 MB view hashes)

Uploaded CPython 3.5m manylinux: glibc 2.12+ i686

gmic-2.8.1.dev7-cp35-cp35m-macosx_10_10_intel.whl (7.3 MB view hashes)

Uploaded CPython 3.5m macOS 10.10+ intel

gmic-2.8.1.dev7-cp34-cp34m-manylinux2010_x86_64.whl (5.1 MB view hashes)

Uploaded CPython 3.4m manylinux: glibc 2.12+ x86-64

gmic-2.8.1.dev7-cp34-cp34m-manylinux2010_i686.whl (4.7 MB view hashes)

Uploaded CPython 3.4m manylinux: glibc 2.12+ i686

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page