G'MIC Tutorial Fragments

Possible Beginner’s Cookbook entry: G’MIC for Python coders.
@myselfhimself has written a Python module that feeds G’MIC command lines to a G’MIC process:

import gmic
gmic.run("sp car,300 b. 10 n. 0,255 o. myblurredcar.png")

puts the file myblurredcar.png in the current working directory. A Pythonista may also keep the image in the Python context by furnishing a list as a second parameter.

myblurredcarlist = list()
gmic.run("sp car,300 b. 10 n. 0,255 o. myblurredcar.png", myblurredcarlist)
len(myblurredcarlist)
1

The purpose of the proposed Cookbook article is not to teach Python folk how to use the module. @myselfhimself has done that. See his Quickstart Guide.

The purpose of the proposed Cookbook article would be to assist Python folk how to compose the command line between the double-quotes, because in short order they will want do do much, much, more than blur Ford coupes. And they can. By lots. But they have to go through a paradigm-shift and it is a complex one (Sorry, David, but it’s true…)

Back history: I started with Linux (Fedora, Red Hat then) in 2010 after moving off of SGI Irix. I discovered gmic in short order, As I did ImageMagick. Both were part of that distro. Couldn’t do much with gmic for - oh about a year and a half. Lotsa black pictures in Gimp. The genesis of the G’MIC documentation arose from my wont of writing out things I don’t understand. I was able to dump ImageMagick for gmic in early 2013 after ImageMagick quirkiness infuriated me. But it took two and a half years to do that. That’s a long time to get over a hump.

The takeaway from that experience, though, was getting a “mental model” of G’MIC: its paradigm. I wish I had it up front. I would have been up to a useful speed with G’MIC in three or four months.

The model which eventually grew up in my head gave rise to these articles:

  1. Basics
  2. Images
  3. Selections and Command Decorations
  4. Images have edges - Now What?
  5. Conjuring Images out of the Aether and Other Generators

The Python Cookbook article would use these articles for a basis and attempt to harness Python-like objects that bear strong similarity to G’MIC objects as a means of building the G’MIC paradigm in a “Python-like” way. In that way, I hope to build the ‘grammar’ of what to put between those double quotes when the Python programmer invokes gmic.run("<some stuff...">)

There is an enormous potential in working with the two paradigms in parallel. My aim, quite frankly, is to promote dual citizens. The Python image processing community is perhaps two orders of magnitude larger than G’MIC’s, but I think having G’MIC in their tool kits could move them to useful images quickly - they just need to be able to read the code. They certainly have useful viewpoints, insights - and code snippets! - to serve as a basis for rich, interesting G’MIC filters. If some Python programmers have G’MIC fluency, the transfer between the two worlds would be enormously useful and healthy for both.

This probably would be one of the more interesting, but intricate, cookbook articles to write. Especially in choosing Python objects that serve as good illustrations of G’MIC constructs. Feedback welcome - and needed. Thank you in advance.

3 Likes