How to Add a Stroke Effect to a Text or Graphic in Krita

Share
In this tutorial, we'll learn how to add a stroke effect to a layer in Krita (version 5.2.2.) that contains a transparent graphic, such as a text, logo, or other shape, e.g. a circle, star, rectangle, square, pentagon, etc. By "stroke" I mean an outline or border. This effect only works on images that have a transparent background. If you have an image with a non-transparent background, you'll need to remove the background first to use this effect.
The word "Stroke" in yellow with a black stroke text effect, made "in Krita."
The stroke effect that you can create in Krita.

To add a stroke effect in Krita, follow the following steps:

1: open the graphic you want to add the effect to in Krita.

2: in the Layers docker, right click on the on the layer (or layer group) of the graphic you want to add a stroke to display its context menu, then select the option Layer Style..., this will open the Layer Styles dialog, which has a list-detail layout.

A panel labelled "Layers." In it, a dropdown list button reads "normal," and a spinner reads "Opacity: 100%." A filter icon button and a hamburger menu button can be seen. The main area is a list with 3 items, labelled "Group 2," "Paint Layer 1," and "Background." The paint layer is indented to indicate that its a child of the group. Several icons can be seen on each layer: an eye icon, a checkbox, a padlock, an icon with the Greek latter alpha, and checkerboard icon, and a brick wall icon. At the bottom, several buttons: a plus with a dropdown, a duplicate icon, a down arrow and up arrow, an icon that resembles sliders with a dropdown, and a trash icon.
Krita's "Layers" docker, featuring a group layer, a paint layer (selected), and a locked background.
A context menu with many items: Properties...; Layer Style...; 9 squares with colors: transparent, blue, green, yellow, orange, brown, red, purple, black; Cut Layer; Copy Layer; Paste Layer; Remove Layer; Duplicate Layer or Mask; Merge with Layer Below; New Layer From Visible; Flatten image; Flatter layer; Select; Group; Toggle Locks & Visibility; Add; Convert; Split Alpha; Pin to Timeline; Isolate Active Layer; Isolate Active Group; Select Opaque (Replace)
The context menu that appears when you right click on a layer in the Layers docker in Krita.

3: on the list pane, you should see Stroke at the bottom, and to its left a square. This is a checkbox. Click on it to check the checkbox. Checking it activates the effect.

4: click on the Stroke in the list pane to customize its parameters in the main pane.

A dialog window titled "Layer Styles - Krita." On its sidebar a checked checkbox "Enable Effects." Under it a list: Styles; Blending Options; (Unchecked) Drop Shadow; (Unchecked) Inner Shadow; (Unchecked) Outer Glow; (Unchecked) Inner Glow; (Unchecked) Bevel and Emboss; (Disabled) Contour; (Disabled) Texture; (Unchecked) Satin; (Unchecked) Color Overlay; (Unchecked) Gradient Overlay; (Unchecked) Pattern Overlay; (Checked and selected) Stroke. On the main pane, the label "Stroke" and under it various settings: Structure: Size (21px), Position (Outside), Blend Mode (Multiply), Opacity (75%); Fill: Color; Color: black. At the right pane, the buttons "Save as..." "Import..." and "Export...". At the bottom, two buttons: OK and Cancel.
Krita's Layer Styles dialog with the Stroke effect enabled (note its checked checkbox) and selected.

Let's understand what each parameter does.

Size: this controls the width of the stroke in pixels. The value must be an integer. We can't, for example, select 0.5 pixels. It must be at least 1 whole pixel.

Position: this controls where the stroke is drawn. We have three options. First is Outside, which creates an outline effect. The important thing about this option it increases the non-transparent area of the layer. For example, if we had a circle with a radius of 100 pixels, and we added a 5px stroke to it, that would add a 5px border to the circle, so the whole radius of the circle would become 105 pixels. The second option is Inside, which does the opposite: the stroke starts at the edge of the graphic but proceeds toward the opaque pixels of the graphic instead of toward the transparent pixels. Reusing the circle example, our 100px radius circle would still have a radius of 100px if we used a 5px stroke; this time the "fill" (non-stroke part) of the circle would become 95px instead. The third option is Center, which makes the stroke half-inside, half-outside. Each of these options can be useful depending on the effect you want to achieve.

  • Outside: you want to preserve the fill and simply add an outline effect to the graphic. This is mostly useful in illustration and graphic design in general. In some applications, this type of setting may also be called "fill over stroke" or something similar.
  • Inside: you want to add a contrasting outline without changing the opaque pixels. This is mostly useful in GUI design, because you can create a rectangle of 100 pixels for a panel and the stroke won't make it larger than you created it.
  • Center: the main reason to use this is if you have multiple layers with this effect and you are placing the layers one next to the other. This makes it so that in areas where one layer touches the other the width of the stroke remains constant.
A diagram showing the difference between three stroke position settings on 4 adjacent squares in Krita. Outside makes the squares appear different sizes and has round corners. Inside creates thicker strokes in the middle between the squres. And center looks perfect with slightly round corners.
The difference between Outside, Inside, and Center stroke positions in Krita.

One surprising detail about how strokes work in Krita is that when the stroke position is set to Center or Inside, the stroke is not "drawn over the fill" as you would normally expect, but, instead, the stroke replaces the fill. This has interesting consequences considering the properties below:

Blend Mode: this is the layer blend mode for the effect. The default is Multiply, and you probably want to change this to Normal, otherwise if you choose a non-black color you'll be able to "see through" the stroke because the stroke color isn't replacing the color on the canvas, it's merely multiplying the color.

Opacity: the opacity of the stroke. the default is 75%, so you probably want to change this too, and make it 100%.

If the stroke position is Center or Inside, the pixels of the stroke replace the pixels of the layer. This means that it's not possible to make the stroke multiply the layer color, because the layer pixels are erased before the stroke is applied. Additionally, this means that if you set Opacity to 0%, it has the interesting effect of "erasing the edges" of the layer instead of adding a stroke.

Fill: this section lets you customize the color of the stroke. The term may be a bit confusing. We aren't talking about "fill AND stroke," we're talking about "the fill OF THE stroke." It starts with a dropdown list button that lets you choose between three types of fills: Color, Gradient, and Pattern. These are common options found around Krita.

  • Color is a flat color, such as black, white, red, or any color you wish.
  • Gradient lets you pick or create a gradient, such as a gradient from black to white. In this case, the stroke becomes gradient-colored instead of having only a single color. You can make it a linear gradient, radial, change the angle, etc.
  • Pattern lets you pick a pattern such as a canvas pattern, a paper pattern, stars, stripes, etc. The pattern changes the transparency of the stroke, which means that if you use an Inside position with a pattern you can see the layer underneath the stroke in pixels where the pattern is transparent, for example.

5: after customizing your stroke, click on the OK button to save your changes. You should see an "Fx" icon on the layers docker next to your layer indicating that the layer has a layer style effect enabled.

Three layers in Krita's layer docker: one labelled "Layer style disabled" with an "Fx" icon in grey; one labelled "Layer style enabled" with an "Fx" icon in white; and one labelled "No layer style" without an "Fx" icon.
The "Fx" icon that indicates if a layer has layer effects in Krita, and if the layer effects are enabled or not.

Creating a Stroke Effect without Layer Styles

It's technically possible to create a stroke-like effect using only filter layers instead of a layer style. To do this you need the following filter layer stack:

  1. A blur filter such as Gaussian blur to expand the non-transparent pixels area of the layer.
  2. A color adjustment curves filter configured to make all alpha values greater than 0 become 100% alpha. This will make the expanded area of the blur become fully opaque and sharp instead of blurry.
  3. A fill layer with inherit alpha to change the color.

Put this stack inside a layer group and place a clone layer of the layer you want to create a stroke for at the bottom.

Although this works, the result isn't anti-aliased, and, at least in version 5.2.2, there is a rendering bug in Krita where if you have a filter layer with a large amount of blur, the blur is strangely "cropped" to fit into invisible squares.

Written by Noel Santos.

About the Author

I'm a self-taught Brazilian programmer graduated in IT from a FATEC. In a world of increasingly complex and essential computers, I decided to use my technical expertise in hardware, desktop applications, and web technologies to create an informative resource to make PC's easier to understand.

View Comments