Posts: 19
Threads: 3
Joined: Sep 2024
Reputation:
0
Operating system(s):
Gimp version: 2.6
10-30-2024, 02:44 PM
(This post was last modified: 10-30-2024, 02:46 PM by inkdolls.)
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.
flattingtools.zip (Size: 1.85 KB / Downloads: 62)
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.
Posts: 6,334
Threads: 271
Joined: Oct 2016
Reputation:
562
Operating system(s):
Gimp version: 2.10
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 :-)
Posts: 19
Threads: 3
Joined: Sep 2024
Reputation:
0
Operating system(s):
Gimp version: 2.6
(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.
Posts: 1,141
Threads: 178
Joined: Sep 2018
Reputation:
113
Operating system(s):
- Windows (Vista and later)
Gimp version: 2.10
(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.
Posts: 19
Threads: 3
Joined: Sep 2024
Reputation:
0
Operating system(s):
Gimp version: 2.6
(11-05-2024, 11:42 AM)denzjos Wrote: Good job. Works fine on windows 10 / gimp 2.10.38.
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.
Posts: 1,511
Threads: 69
Joined: May 2021
Reputation:
167
Operating system(s):
Gimp version: 2.10
11-06-2024, 05:54 AM
(This post was last modified: 11-06-2024, 06:07 AM by PixLab.)
(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.
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
it's on the code
multifill (line 119) is "RGB*, GRAY*, INDEXED*",
BUT flatten colors (line 150) is only "RGB*, GRAY*", (no indexed)
Patrice
Posts: 19
Threads: 3
Joined: Sep 2024
Reputation:
0
Operating system(s):
Gimp version: 2.6
11-07-2024, 06:45 PM
(This post was last modified: 11-07-2024, 06:46 PM by inkdolls.)
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:
flattingtools.zip (Size: 1.9 KB / Downloads: 8)
(11-06-2024, 05:54 AM)PixLab Wrote: No a bug in python,
Looks like an indexed/rgb problem, put it RGB
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.
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.
|