How to Use Adjustment Layers in PSD Using Aspose.PSD for .NET
Adjustment layers enable creative and non-destructive edits to colors and tones in PSDs. Aspose.PSD for .NET lets you script and automate Curves, Levels, and Color Balance just like in Photoshop.
Real-World Problem
Designers often need to fine-tune color or brightness in batches of PSDs for branding, corrections, or seasonal campaigns. Doing this by hand is slow and inconsistent.
Solution Overview
Programmatically add or update Curves, Levels, or Color Balance adjustment layers with precise settings in a few lines of code.
Prerequisites
- Visual Studio 2019 or later
- .NET 6.0 or later (or .NET Framework 4.6.2+)
- Aspose.PSD for .NET from NuGet
- PSD file to process
PM> Install-Package Aspose.PSD
Step-by-Step Implementation
Step 1: Load the PSD File
using Aspose.PSD;
using Aspose.PSD.FileFormats.Psd;
string inputFile = "./input/sample_with_adjustment.psd";
string outputFile = "./output/sample_adjusted.psd";
var loadOptions = new PsdLoadOptions() { LoadEffectsResource = true };
PsdImage psdImage = (PsdImage)Image.Load(inputFile, loadOptions);
Step 2: Add or Locate an Adjustment Layer
// Add a Curves Adjustment Layer
auto curvesLayer = psdImage.AddCurvesAdjustmentLayer();
// Or, add a Color Balance Adjustment Layer
auto colorBalanceLayer = psdImage.AddColorBalanceAdjustmentLayer();
Step 3: Edit Curves Adjustment
var curveManager = curvesLayer.GetCurvesManager();
curveManager.AddCurvePoint(0, 50, 32); // Example: adds a point at channel 0
Step 4: Edit Color Balance Adjustment
colorBalanceLayer.ShadowsYellowBlueBalance = 42;
colorBalanceLayer.MidtonesMagentaGreenBalance = 18;
Step 5: Save the Adjusted PSD
psdImage.Save(outputFile);
psdImage.Dispose();
Use Cases and Applications
- Brand-compliant color grading on batches of assets
- Quick seasonal tone shifts for campaigns
- Automated correction of scanned or legacy graphics
Common Challenges and Solutions
No visible effect: Confirm layer order and settings; adjustment layers must be above layers to affect them.
Wrong adjustment type: Use the correct method for the desired adjustment (Curves, Color Balance, etc.)
Best Practices
- Keep originals for easy rollback
- Validate color and tone in Photoshop after automation
- Document adjustment logic for traceability
FAQ
Q: Can I automate other adjustment types? A: Yes—Brightness/Contrast, Exposure, Levels, etc. are also supported by similar API methods.
Q: Can I edit an existing adjustment layer? A: Yes—locate it by type and modify its properties.
Conclusion
With Aspose.PSD for .NET, professional color and tone adjustment is just a script away. See Aspose.PSD for .NET API Reference for full options.