You can read more details at: Apply Gaussian Blur Filter on Images in C#
Last active
April 25, 2022 22:36
-
-
Save aspose-com-gists/10185f09105af11426103c583715068c to your computer and use it in GitHub Desktop.
Apply Gaussian Blur Filter to an Image in C# .NET
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string sourceFile = "layers.psd"; | |
string outputPsd = "out_test.psd"; | |
string outputPng = "out_test.png"; | |
using (var image = (PsdImage)Image.Load(sourceFile)) | |
{ | |
SmartObjectLayer smartLayer = (SmartObjectLayer)image.Layers[1]; | |
Layer maskLayer = image.Layers[2]; | |
Layer regularLayer = image.Layers[3]; | |
// Apply Gaussian blur filter | |
GaussianBlurSmartFilter gaussianBlur = new GaussianBlurSmartFilter(); | |
gaussianBlur.Radius = 10; | |
gaussianBlur.Opacity = 50; | |
// Apply filter to SmartObject | |
gaussianBlur.Apply(smartLayer); | |
smartLayer.SmartFilters.UpdateResourceValues(); | |
smartLayer.UpdateModifiedContent(); | |
// Apply filter to layer mask | |
gaussianBlur.ApplyToMask(maskLayer); | |
// Apply filter to layer | |
gaussianBlur.Apply(regularLayer); | |
// Save output as PSD and PNG Image | |
image.Save(outputPsd); | |
image.Save(outputPng, new ImageOptions.PngOptions() { ColorType = PngColorType.TruecolorWithAlpha }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment