Magic behind layer styles

Log-in or register.
rsrc/lrst.png image

Introduction to layer styles


March 15th 2011

This article explains what are layer styles in image editors, when to use them and a bit about how they are working internally. Readers should be familiar with computer images and basic image effects.

What are layer styles?

Look at the following images. The right one was obtained from the left one by applying a couple of image effects, namely Fill, Outline, Bevel, and Drop shadow.

rsrc/layerstyles-source.png image
Image without styles.
rsrc/layerstyles-applied.png image
Image with styles applied.

Applying these effects manually would not be hard. Clicking a toolbar button or finding the command in the main menu, then playing with the parameters of each effect. 2 minutes max. No problem.

What if the letters needed to be modified afterward? That could take some time. First, the old content must be deleted and re-created with changes and then re-applying all the effects. Odds are the parameters would be slightly different. Was it a 5px drop shadow or 6px drop shadow? Who knows? And, of course, applying the effects takes another 2 minutes of clicking.

This is where layers styles help. A layer style is a collection of image effects applied to an image (layer) behind the scene. While the actual content of the image remains unchanged, the user sees the image with effects applied. When the content of a layer changes, the effects are re-applied automatically with exactly the same parameters.

How do layer styles work?

Using layer styles (and adjustments layers) is sometimes called non-destructive editing. The parameters of a layer style may be changed at any time or the layer style may be removed restoring the image to the original state.

When a layered image is saved to the hard drive, the editor saves the original (not styled) image and the information about the style. If the image is re-opened later, the style can be removed and the original image (photo) is still available. An image editor remembers the original image and the information about the selected style, but displays the image with the styles applied.

When an image is saved to one of the standard image formats like .jpg or .png, the information about the structure of the image is lost - the style cannot be removed anymore.

What is the problem?

As stated above, when user is modifying a layer with a style applied to it, the computer must continually re-apply the style to accommodate the changes. A style can be quite complex and applying it may be time consuming. The problem, of course, is speed.

If applying of a layer style took 1 second, users would have to wait 1 second before seeing the result of their action (like drawing a rectangle). This is not acceptable. To work at sufficient speed, the image editor implements several speed optimizations. It must:

  • Correctly determine the affected region. For example when drawing a rectangle on a layer with shadow as the layer style, the affected region includes the pixels of the rectangle, but also the pixels near the rectangle, because the rectangle casts a shadow,
  • Apply the effect only to the affected region of the image.
  • Split the affected region and apply the effect in parallel using multiple cores of today's processors.

Correctly implementing the above points is not an easy task and it is no wonder you will find layer styles in few image editors.

Layer styles in current image editors

Photoshop

Photoshop offers a layer style that consists of predefined image effects including shadow, bevel, glow, outline and various filling gradients or textures. The style is applied on the fly and is very fast.

rsrc/layerstyles-photoshop.png image
Layer style configuration window in Photoshop.

Photoshop's has one mega-effect consisting from multiple individual effects that can be enabled using the check-boxes to the left of the effect and configured when clicked on.

The GIMP

GIMP does not support layer styles on its own - there is a plug-in for that. While a geek can argue that GIMP supports layer styles, the ease of use is very far from what Photoshop offers. For a normal user, there are no layer styles in GIMP.

Paintshop Photo Pro

Corel's image editor partially supports layer styles. It can do shadows, bevel, glow and a strange effect that does not seem to do anything visible called reflection. Paintshop does not apply the effect continuously - it turns them off while drawing and re-enables them afterward.

SUMO Paint

Sumo Paint is a nice Flash-based image editor. It has a half-baked layer style support, just like Paintshop - it only applies the layer styles after you finish drawing.

RealWorld editors

RealWorld Photos and other RealWorld tools can use any of its image effects or combination of effects as a layer style.

rsrc/layer-styles-config.png image
Configuring layer styles in RealWorld tools.

To access the above window, click on Layer->Layer style->Modify style in the main menu or above the list of layers.

The advantage of this approach is much higher flexibility - even a plug-in can be used as a layer effect. The downside is the increased difficulty of the configuration. User must first add the effect to the layer style and then configure it.

The order of effects affects the end result. While the order of effects is fixed for Photoshop and other image editors, RealWorld leaves this aspect of layer style on the users. Hints:

  • Put fills at the start, because they change all pixels in the image. If you for example placed fill after drop shadow, the shadow color would be affected by the fill style.
  • Place bevel before drop shadow or glow. You would not want to bevel the shadow shape. Learn about bevel.
  • Using the same effect multiple times may give interesting results. For example using drop shadow twice with different colors gives a nice effect.

When to use layer styles?

Each time you are applying an effect to an image, consider adding it to the layer style instead of applying it directly. If there is a chance that you would want to modify the raw image later, choose the layer effect.

Here are a few tips:

  • Start small and learn to build a more complex style over time.
  • Bevel and drop shadow work very well with text.
  • Use the save/load functionality to build a library of your favorite layer styles.
  • Layer styles can be copied and pasted.
  • Layer effects in RealWorld do not have access to the current selection - they always affect to the whole layer.
  • Some filters are not optimized (or cannot be easily optimized) for speed and make a poor layer effects. If the application slows down considerably after adding an effect, you may be better off applying it directly.
  • RealWorld applications can show you the raw layer without effect - click on Show active layer only in View menu or toolbar. To return back to the default view mode, click on Show all layers.

Recent comments

user icon arabico registered user on December 22nd 2020

FIRST! 8-)

user icon RIDDLER registered user on April 15th 2021

Photoshop is not available on RealWorld Graphics.

user icon Anonymous
What about ICL files?
Vista & Win 7 icons