Exporting images without shadow effect
image.jpg (86.8 KB)
To export images from a PSD file without the shadow effect, you can manipulate the layer styles of the image before saving it. Specifically, you will want to clear any drop shadow effects applied to the layers. Here’s a general approach you can follow using Aspose.PSD:
- Load the PSD file.
- Iterate through the layers and check for any shadow effects.
- Remove or disable the shadow effects.
- Save the image in your desired format.
Here’s a sample code snippet demonstrating this process:
using Aspose.PSD;
using Aspose.PSD.FileFormats.Psd;
using Aspose.PSD.FileFormats.Psd.Layers.Animation;
string inputPsdFile = "input.psd";
string outputImageFile = "output.png";
using (PsdImage psdImage = (PsdImage)Image.Load(inputPsdFile))
{
foreach (var layer in psdImage.Layers)
{
// Check if the layer has any effects
if (layer is LayerStateEffects effects)
{
// Clear any drop shadow effects
effects.ClearLayerStyle();
}
}
// Save the image without shadow effects
psdImage.Save(outputImageFile, new PngOptions());
}
In this code, we load the PSD file and iterate through each layer. If a layer has effects, we clear them, which includes any shadow effects. Finally, we save the modified image to a new file.
Make sure to adjust the file paths and formats as needed for your specific use case. This approach should help you export images without any shadow effects applied.
@hellokimi56 could you please provide input file to help us check the issue.
Aspose.PSD doesn’t render shadow as default.
Please check this:
This code should help you:
var psdLoadOptions = new PsdLoadOptions() { LoadEffectsResource = true };
using (PsdImage image = (PsdImage)Image.Load(sourceFileName, psdLoadOptions))
{
}
Also, Aspose.PSD doesn’t render warp effect by default.
For the warp rendering please check this:
using (var psdImage = (PsdImage)Image.Load(sourceFile, new PsdLoadOptions() { AllowWarpRepaint = true, LoadEffectsResource = true })) {}
Can you provide me with Python code? Thanks
@hellokimi56 please check the following code snippet:
# Specify Load Options
loadOptions = PsdLoadOptions()
loadOptions.load_effects_resource = True
loadOptions.allow_warp_repaint = True
# Specify Export Options
exportOptions = PngOptions()
exportOptions.color_type = PngColorType.TRUECOLOR_WITH_ALPHA
# Open File using Aspose.PSD for Python
with Image.load(sourceFile, loadOptions) as image:
# Export PSD File To PNG
psdImage.save(outputFile, exportOptions)
If you need additional information about using of Python version, please check this:
Thanks! Thanks!