Newspaper plugin for halftoning

Hi

Still testing Krita plugin creation, but next level :slight_smile:

The Newspaper plugin allows to apply halftone effect on an image.

What is Newspaper plugin?

Newspaper is a Python plugin made for Krita and allows to apply halftone effect with different options

Download & Install

You can download it on Github:

Installation process is defined on github page.

What’s new?

[2020-06-23] Version 1.1.1

  • Compatibility with Krita 4.3.0

[2020-05-01] Version 1.1.0

  • Add Three color (CMY - Pictures) mode
    No black layer, Black key is obtained by the combination of Cyan, Magenta, Yellow
  • Add a Four color (CMY+K - Pictures) mode
    Use of registration black: black key is obtained by the combination of Cyan, Magenta, Yellow, and an additional black layer is added
  • Improve the Four color (CMY+K - Comics #2)

Bugs

Plugin has been tested with Krita 4.3.0 (appimage) on Linux Debian 10

  • Tested on MacOS Catalina by @Carlos [thanks!], seems to work (Version 4.2.9)
  • Not tested on Linux non-appimage (ie: appimage include Python 3.8 + needed Qt libraries)
  • Tested on Windows 10 by @slls666 [thanks!], seems to work (Version 4.2.9)
  • Tested on Windows 8.1 by @djwaterman [thanks!], seems to work (Version 4.2.9)

There’s might be some bugs but and code may not be optimized, but it’s a first release :wink:

:warning: Please take in account that on big images, the plugin can be slow: I tried to optimize processing code but Python scripts execution is slow and it’s not a language designed to natively work on big array of data (usually, fast calculation operations with Python are made with additional NumPy and SciPy libraries)

What’s next?

  • Some improvements can be made to user interface
    – Allow to zoom in/out preview
    – Allow to pan preview
  • Maybe adding a preset management allowing user to save preferred configuration(s) rather than having to redefine everything each time :grimacing:
  • Speedup processing using multi-thread

Use

Use of plugin is quite simple:

  • Select a paint layer layer in active document (layer must be 8bits RGBA layer)
  • Execute script Tools > Scripts > Newspaper
  • Choose options from user interface and click OK

Detailed options description:

Mode

There’s 6 available modes:

  • Monochrome
    This mode allows to convert image to black & white halftone effect

  • Three color (CMY - Pictures)
    This mode allows to convert image to colored halftone effect with CMY separations; the black key is obtained by a combination of Cyan, Magenta and Yellow
    – This mode is the best for pictures and painting without clean black lines

  • Four color (CMYK - Pictures)
    This mode allows to convert image to colored halftone effect with CMYK separations
    – This mode is the best for pictures and painting without clean black lines

  • Four color (CMY+K - Pictures)
    This mode allows to convert image to colored halftone effect with CMYK separations and use a registration black; the black key is obtained by the combination of Cyan, Magenta, Yellow and an additional black layer is added
    – This mode is the best for pictures and painting without clean black lines

  • Four color (CMY+K - Comics #1)
    This mode allows to convert image to colored halftone effect with CMY separations, and try to keep black key unchanged
    – This mode is better for pictures with clean black lines (like in comics)

  • Four color (CMY+K - Comics #2)
    This mode allows to convert image to colored halftone effect with CMY separations, and try to isolate black key with a reduction of grey levels
    – This mode is better for pictures with clean black lines (like in comics)

Style preview

The style preview is a fast sample to check results with current applied applied options.
There’s 2 available samples:

:point_right: When mouse is over the style preview, model used is displayed
:point_right: When mouse is not over the style preview, result is displayed

Click on style preview to switch between B&W and Color gradient model

Dot shape

There’s 5 available shapes to apply halftone effect:

  • Circle
    The classic dot, draw circles to create halftone effect

  • Diamond
    Draw diamonds to create halftone effect

  • Square
    Draw squares to create halftone effect

  • Flat line
    Draw a line with flat/butt stroke to create halftone effect

  • Rounded line
    Draw a line with rounded stroke to create halftone effect

Size

Define size of a full dot
Can be defined between 2.5px and 30px

Adjustment

Distance between 2 dots is calculated automatically according to dot full size
The adjustment allows to change the distance from -50% to 50%:

  • With negative values, a full dots will overlap each other
  • With zero value, 2 full dots will be drawn aside
  • With positives values, 2 full dots will be drawn with a space
Steadiness

Allows to provides some ‘chaos’ into dot shape:

  • A value of 1 will generate deformed dot
  • A value of 10 will generate perfect dot
Sampling

The sampling define how a dot size is calculated:

  • Low
    Only one pixel of full dot area is used
  • Medium
    50% of pixels of full dot area is used
  • High
    All pixels of full dot area is used

The default Medium is a good compromise between quality and speed

Antialiasing
  • None
    No antialiasing is applied, result will provide sharp pixelated dots
  • Normal
    Antialiasing is applied to draw dots, result will provide smooth dots
  • Soft
    Antialiasing is applied to draw dots and then a light gaussian blur filter is applied, result will provide smooth dots
(Monochrome option) Desaturate mode

This option is available for Monochrome mode only
It allows to define which desaturation method is applied to build monochrome halftone; available methods are the same than Krita’s Desaturate filter

(Monochrome option) Rotation

This option is available for Monochrome mode only
Allows to define the angle applied to draw dots

(Monochrome option) Foreground color

This option is available for Monochrome mode only
Allows to define dots color

(Monochrome option) Background color

This option is available for Monochrome mode only
Allows to define background color
If checked, option Transparent allows to generate halftone effect on a transparent background

(CMYK option) Screen angle

This option is available for CMYK and CMY+K modes only
Allows to define screen angle for CMYK halftone rendering

Refresh button

Due to execution time, preview on layer is not applied in live and you should be made manually by clicking the Refresh button :slight_smile:

Why Newspaper?

I was inspired by @djwaterman artwork A Lady Enters and the fact there’s was no possibility to do it in Krita, so I found interesting to understand how to create a halftone filter :sweat_smile:

Additionally, I was not completely satisfied by Krita’s halftone native filter… (I’ve used it for General Buli and EcoBuli drawings)

Results from plugin are not as good as Photoshop and Gimp filters, especially for CMYK results, but I’m not an expert :wink:
But IMHO results for monochrome mode are better than one obtained with Krita’s halftone filter :upside_down_face:

Source | Krita’s halftone filter | Newspaper plugin

Enjoy

Grum999

9 Likes

I read this as “what is a newspaper” and thought: Are we really at the point already where we have to explain this to people. xD

Anyway, cool plug-in.

2 Likes

ah :sweat_smile:

I changed to “What is Newspaper plugin?”
:wink:

Grum999

wow thanks,
I tried in windows 10 it works perfectly.

Cool work :slight_smile: thanks for the plug-in.

Thanks for information :+1:

Thanks :grinning:

Grum999

Love it! Could be very useful!

Might it be worth it for you to rewrite this plugin in cpp, so we can use it to replace the current halftone filter? The bugs it has is because when I worked on it, I tried to make it multi-threaded (so it could be used as a filterlayer), but that kinda failed.

Hi @wolthera

I agree that using C++ for this plugin would be great for performances (and for Krita also, to have this natively in filters :wink: ), but for now I’m not just able to do it.

I already tried to understand code from krita/plugins/filters/halftone/kis_halftone_filter.cpp file because it’s not working properly when called from PyKrita API, but for now even if I’m able to understand the code in his globality, as I already told to @tiar I think I’ve some step to pass before starting to work on Krita’s source code:

  • I’m relatively a newbie with C++ language
  • I need to understand Krita’s dedicated Kis* classes and architecture
  • I need to learn Qt a little bit more (with this plugin I think I now have some basis, but not enough, and working on python plugin with PyQt is easier for me to learn Qt concept than trying to learn Qt and C++ at the same time)
  • I need to learn how to use git (ok I’ve already started this point :wink: )
  • I need to be able to compile Krita (next step after git learning, should not be so difficult, but it’s another step to learn)
  • I need time (I currently have 2 more plugins in my mind and I want to be able to work on them before really starting C++)

So for now we will have do with the python plugin, waiting to have something better in Krita’s native filters, I think it’s a nice workaround :wink:

And in few month I’ll try to work on a C++ version of the plugin, but before I think I need to try to fix one or two bug that @tiar listed as they’re defined as ‘relatively easy’.

But as you can see the plugin provides many options and it won’t be just trying to fix problem with current halftone filter, it make sense to code the plugin with C++ only if all current plugin functionalities and options are reported in C++

In any case, the fact you asked me to rewrite the plugin as a native C++ to be part of Krita touches me and comforts me on the quality of the plugin :slight_smile:

Grum999

I don’t think you should aim so high… I haven’t achieved it yet and I’m still being useful :stuck_out_tongue: Just run

grep -Rn "search phrase"

in the source directory and you’re good to go :stuck_out_tongue: (I need to make a blog post about tips for developing on Krita, looks like it might be useful)

Not saying it’s unnecessary, but git commands are something that one can give you if needed. Also there is this guide: https://docs.krita.org/en/untranslatable_pages/intro_hacking_krita.html#contributing-patches which basically contains everything except for applying patches provided by other people (I need to include that, too :wink: and finally move to its own page…)

It could be a separate halftone filter, like there are two Blur ones. Or it could replace the old one if there is no usecases where the old one is better.

Of course I’m not saying that you should right now start to write it in c++ and be done in a week :slight_smile: I’m happy you consider contributing, and I just thought it would be good to reduce some of your worries, that’s all. Having it as a plugin already looks really useful :slight_smile:

2 Likes

Thanks :slightly_smiling_face:

Yes there’s some worries, especially because when I don’t have mastery about what I’m doing or when I don’t really understand what I’m doing, I’m afraid to make mistake and broke something, and finally I have no pleasure to do it.
So this is why I prefer to (slowly) learn a minimum before starting to really contribute :wink:

Grum999

1 Like

That’s why I like this website, you get things like this being created. I couldn’t get the plugin to work so I downloaded the latest version of Krita. I’m on Windows 8.1, now it works. I did a test with Newspaper, in combination with Channels2Layers script, so I did a newspaper operation on each color output and used the color picker in the monochrome setting to get my CMY tone layers and combined them with multiply modes.

I need to experiment more with this plugin and get to know it better, but so far it’s really inspiring me.

Hi!

To work, the plugin needs Krita 4.2.9 due to some code that need Python 3.8
Maybe I can made some change to let him being compatible with Krita 4.2.8, I need to check what to do for this…

In fact, the plugin Newspaper allows to to work directly on CMYK colors without having to use Colors2Channels; there’s 3 dedicated modes for this :wink:
There’s a small description in initial post, but as it’s a collapsible section maybe it’s not really visible (need to click on ‘Detailed options description’)

The plugin will split the C,M,Y+K channels automatically and will apply the right screen angle to each color properly to reduce “moiré” effect.

Grum999

During my development tests I was wondering how you was able to keep proper clean black lines, because on my side if we really decompose CMYK from a flat image, the black lines are not so clean as before due to the halftone… (this why I tried to create the “Four color (CMY+K - Comics #1)” and “Four color (CMY+K - Comics #2)” modes :slight_smile:

But if I understood, you apply halftone on a dedicated colored layer (without black) and keep the original clean black line above?

Grum999

Yes correct, I keep the black ink layer separate. I can’t remember why I felt it necessary to go with Channels2layers, I used it the way you said first before I went ahead to do it my way. I think the result color match wasn’t as close to the original or something, (from memory I think when I took out the K layer it removed a lot of the color depth and looked washed out) but I will play around with the default some more and see if I can get the results I’d like. Thanks for doing this, it just gives us more options within Krita.

PS didn’t see the collapsible section in original post, that info is important and I probably didn’t choose a good mode, so I’ll give all that a good read and experiment more.

In fact, by applying an halftone effect to each CMY color channels will provide a washed out effect, it’s not possible to get the original as dots are separated with blank (this visual example might be better than my explanation :slight_smile:)

But if you’re working on pure colored layer, without any black value, I may need to add a “Three Color (CMY)” mode that will provide better results, because the actual 3 colors mode implemented “remove” the black key information from color before processing.

You can also try to play with the “adjusment” option, that allow to change the distance between dots (so, less blank means more color intensity…)

If you want, you can send me a version of your drawing (one layer black, one colored, and do not need full size) to do development tests on it as a reference…

Grum999

Thanks, I’m playing around ATM, and your Three Color option sounds like a good one to me.

You can combine these two images into kra file for testing if it helps.


Thanks for the files :slight_smile:

I’ve made a quick test with a 3 colors CMY implementation:

  • Working with a separate color layer provide in any case better results than trying to isolate the black key
  • The result with CMY instead of CMYK seems to be better!

Here 3 example of what I got:
Dot Size = 5px


Dot Size = 7px

Dot Size = 6px / Adjustment = -10%

The last one provide more saturated colors.
I think it’s possible to got better results with a better configuration of dot size and adjustment values, but for now I don’t have the time to play more…

based from your drawing, I will try to see if I can made optimized modes, but in any case I think to publish the version with “Three color (CMY)” mode tomorrow (not sure to have time today/tonight)

Grum999

1 Like

Oh yeah, you really solved it.

1 Like

Yes it seems :blush:

Version 1.1.0 has been published (I’ve updated main thread of this topic)

Here the last results I got with your drawing:

All tests made with the following parameters:
Dot size: 6.5px
Adjustment: -10%
Sampling: high

Mode: Three color (CMY - Pictures) / Applied on color layer

Mode: Four color (CMYK - Pictures) / Applied on color layer

Mode: Four color (CMY+K - Pictures) / Applied on color layer

Mode: Four color (CMY+K - Comics #2) / Applied on merged black lines + color layer


Fot his last one, the result is quite good I think as it’s not easy to separate the black lines properly (for this we need a good quality image like one you’ve provided: large size, no JPEG artifacts, proper black line with a good separation with color)

Grum999

1 Like

Stella work. I’ve been thinking about this and what could be useful would be a save settings option for the plugin. If one has a tone setting that they find works on a project, then being able to load those in would speed up things. ATM you’d have to write those numbers down.

Anyway, something to think about, the plugin is really good as it is.