Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multifill, flatting tools for comics and illustrations, fast and python only
#1
I wrote a plugin long ago to help me in coloring comic pages:

1: Outline image darkened a bit (to minimize gaps) and converted to two bit indexed black and white. 2: Multifill filter fills with random colors. 3: Outlines removed with flatten filter.
   

Random colors replaced. Outline added back as a layer in multiply mode. Shading applied.
   

I wrote this in 2013 and I regret not having shared it, the only other option was a very slow script on the Gimp Registry. I wrote mine with its own logic not using any Gimp features except access to image data. I wrote it in C and it's fast, even on old 32 bit machines. But I never dared to show my C code and I couldn't have compiled anything on other platforms but Linux.

Only very recently I found out by accident about the low level access to gimp images with Python. I ported the code just to try. The result is not as fast, but it's quite reasonable, taking a few seconds and not minutes or hours to finish.

My script is dumb, it can't find gaps or merge small areas with the surrounding ones, someday maybe. I know Gimp now has filling with line art detection and there's also an advanced "smart coloring" GMIC filter. But the workflow with line art detection is not great for me, I have to work faster. And being Qt based, gimp-gmic requires that I install 44 packages and use extra 107 MB of disk, versus my tiny plugins that only take a few Kb.


.zip   flattingtools.zip (Size: 1.85 KB / Downloads: 76)

The flatting tool (edge removal) is copied from the one written by Rob Antonishen that uses the dilate filter, in this case my code would be slower in python.
Reply
#2
Nice...

Hard to avoid all Qt-based apps so sooner or later you are going to install the Qt support (me, I'm on KDE so Qt support is a given). And what is 104MB these days? I have Gimp XCF files bigger than this :-)
Reply
#3
(10-30-2024, 05:04 PM)Ofnuts Wrote: Nice...

Hard to avoid all Qt-based apps so sooner or later you are going to install the Qt support (me, I'm on KDE so Qt support is a given). And what is 104MB these days? I have Gimp XCF files bigger than this :-)

Yeah, I miss the old KDE that allowed different desktop backgrounds... But I use XFCE now.

And you're right about the file size, images can quickly fill several GB, even compressed.
Reply
#4
(10-30-2024, 02:44 PM)inkdolls Wrote: I wrote a plugin long ago to help me in coloring comic pages:

1: Outline image darkened a bit (to minimize gaps) and converted to two bit indexed black and white. 2: Multifill filter fills with random colors. 3: Outlines removed with flatten filter.


Random colors replaced. Outline added back as a layer in multiply mode. Shading applied.


I wrote this in 2013 and I regret not having shared it, the only other option was a very slow script on the Gimp Registry. I wrote mine with its own logic not using any Gimp features except access to image data. I wrote it in C and it's fast, even on old 32 bit machines. But I never dared to show my C code and I couldn't have compiled anything on other platforms but Linux.

Only very recently I found out by accident about the low level access to gimp images with Python. I ported the code just to try. The result is not as fast, but it's quite reasonable, taking a few seconds and not minutes or hours to finish.

My script is dumb, it can't find gaps or merge small areas with the surrounding ones, someday maybe. I know Gimp now has filling with line art detection and there's also an advanced "smart coloring" GMIC filter. But the workflow with line art detection is not great for me, I have to work faster. And being Qt based, gimp-gmic requires that I install 44 packages and use extra 107 MB of disk, versus my tiny plugins that only take a few Kb.



The flatting tool (edge removal) is copied from the one written by Rob Antonishen that uses the dilate filter, in this case my code would be slower in python.

Good job. Works fine on windows 10 / gimp 2.10.38.  Cool
Reply
#5
(11-05-2024, 11:42 AM)denzjos Wrote: Good job. Works fine on windows 10 / gimp 2.10.38.  Cool

Thanks!

By the way, if somebody gets distorted results like this, I think there's a bug in the python interpreter:

   
   

For two-bit indexed images with alpha channel,  the script gets the wrong bits per pixel, so either remove the alpha channel or convert to rgb.
Reply
#6
(11-05-2024, 11:54 PM)inkdolls Wrote:
(11-05-2024, 11:42 AM)denzjos Wrote: Good job. Works fine on windows 10 / gimp 2.10.38.  Cool

Thanks!

By the way, if somebody gets distorted results like this, I think there's a bug in the python interpreter:

For two-bit indexed images with alpha channel,  the script gets the wrong bits per pixel, so either remove the alpha channel or convert to rgb.

No a bug in python,
Looks like an indexed/rgb problem, put it RGB Wink
it's on the code
multifill (line 119) is "RGB*, GRAY*, INDEXED*",
BUT flatten colors (line 150) is only "RGB*, GRAY*", (no indexed)
Patrice
Reply
#7
So, I seem to have fixed the distortion issue.

I can't edit my previous posts, it's not great to not have some external repository, so I just hope this will be noticed. This is a fixed version, sorry about that:


.zip   flattingtools.zip (Size: 1.9 KB / Downloads: 10)

(11-06-2024, 05:54 AM)PixLab Wrote: No a bug in python,
Looks like an indexed/rgb problem, put it RGB Wink
it's on the code
multifill (line 119) is "RGB*, GRAY*, INDEXED*",
BUT flatten colors (line 150) is only "RGB*, GRAY*", (no indexed)

Um, that part on line 150 is copied from an old script. It doesn't have to match the previous declaration since it's for another plugin. I did test and adding INDEXED* makes Gimp go into an infinite loop if an actual indexed image is used.

Smile But thanks for making me look at he code again. GImp is not reporting a wrong bites per pixel number. I was storing it before a possible conversion to rgb, in which case it would not be valid anymore.
Reply


Forum Jump: