Add Fill Layer in Photoshop Document (PSD file) – Easy Guide

Add fill layer in photoshop

Photos are a very useful way of reflecting information. PSD format files are used to create images. However, there could be scenarios like editing several Photoshop files along the same lines. For instance, a photo processing application may need to add a layer in multiple Photoshop documents, along with other operations. Aspose.PSD for .NET API offers many features to work with PSD, PSB, AI, and many other file formats. Let us explore the following use cases related to adding a layer in PSD files:

Add Fill Layer at Runtime in Photoshop Document using C#

Aspose.PSD for .NET API supports creating a fill layer in a PSD file. You do not necessarily need to load the layer from an existing file. Simply follow below steps to add a fill layer at runtime in the PSD file:

  1. Initialize an instance of PsdImage class with page dimensions
  2. Create an instance of FillLayer class
  3. Set Display Name for the layer
  4. Add the layer to the image

Following code snippet shows how to add fill layer in Photoshop using C#:

This code snippet will generate a PSD file of specified dimensions where the screenshot below is showing names of three fill layers exactly as set by C# code above:

Add Layer in Photoshop

Add Existing Fill Layer in PSD file using C#

We have already learned about creating and adding new fill layers. Let us check out how to add layer from existing Photoshop file. Following are the possibilities of adding existing fill layers:

i) Add Layer with Pattern Fill using C#

A pattern fill may have an image, line, or shadow to fill the area. You need to follow the steps below for adding a layer with Patten Fill in a PSD image:

  1. Load source PSD file
  2. Iterate through all layers and check for FillLayer
  3. Set different settings for the layer
  4. Edit the Fill Layer
  5. Save the image

The code snippet below shows how to add fill layer with Pattern fill using C#:

ii) Add Layer with Gradient Fill using C#

You can also use Gradient fill for filling a layer in Photoshop Document. Aspose.PSD for .NET API supports the following types of Gradient fills:

  • Linear
  • Diamond
  • Radial
  • Reflected
  • Angle

Below are the steps for adding a layer with a gradient fill:

The code snippet below is based on these steps and shows how to add GradientFill layer in Photoshop document using C#:

This code snippet will generate five different files, each with a different kind of Gradient fill in the layer of the PSD file.

iii) Add Layer with Color Fill using C#

You can add a layer with Color fill in Photoshop Document, a PSD file. Follow the steps below for adding or creating a Fill Layer with Color Fill:

  1. Load source PSD image
  2. Check all layers and find FillLayer
  3. Read fill settings of the layer
  4. Set fill color and update the layer
  5. Save the PSD image

The code snippet below is based on the aforementioned steps that show how to add fill layer in Photoshop Document using C#:

Conclusion

In this article, we have explored few of the many possibilities of adding fill layers in PSD files. We have learned how to add a layer from scratch, as well as how to add layers from existing PSD files. Different types of Gradient fill layers are also addressed along with examples. There are many other exciting features offered by Aspose.PSD for .NET API. Please feel free to get in touch with us via Free Support Forums in case of any concerns.

See Also

Find Layers and Update Layer’s Text or Image in Photoshop Files