how to assign the background layer for particulaur psd image layer
i am refered this side : Photoshop Layers - The Background Layer
so, how to implement aspose using any idea share about…
how to assign the background layer for particulaur psd image layer
i am refered this side : Photoshop Layers - The Background Layer
so, how to implement aspose using any idea share about…
I have observed your comments and created investigation ticket with ID PSDNET-313 to further investigate either your requirements are possible with Aspose.PSD or not. We will share good news with you soon.
aspose .imageing library used
I like to share that for PSD files, we recommend to use Aspose.PSD and not Aspose.Imaging. The support for PSD files will no more continued in Aspose.Imaging.
ok thanks,
Aspose.PSD using the psd image layer create an particular layer is ‘BACKGROUND FROM LAYER’
We will investigate the requirement on our end to help you further as soon as feedback is shared for associated ticket.
investigation ticket with ID PSDNET-313
Can you please try to use following sample code on your end and share feedback with us if it helps you.
// Check if Layer is Background
static bool IsLayerIsBackground(Layer layer)
{
return
!layer.HasAlpha &&
layer.LayerLock == (LayerLockType.LockTransparentPixels | LayerLockType.LockPosition) &&
layer.Name == "Background" &&
layer.Flags == (LayerFlags.HasUsefulInformation | LayerFlags.TransparencyProtected);
}
static void MakeLayerToBeBackground(Layer layer)
{
layer.Name = "Background";
layer.LayerLock = LayerLockType.LockTransparentPixels | LayerLockType.LockPosition;
layer.Flags = layer.Flags | LayerFlags.TransparencyProtected;
// Removing of Alpha channel
var channels = new List<ChannelInformation>();
if (layer.HasAlpha)
{
for (int i = 0; i < layer.ChannelsCount; i++)
{
if (layer.ChannelInformation[i].ChannelID != -1)
{
channels.Add(layer.ChannelInformation[i]);
}
}
layer.ChannelInformation = channels.ToArray();
}
}
// Example code
string sourceFileName = "Background.psd";
// Background layer is created in PhotoShop
using (var psd = (PsdImage)Image.Load(sourceFileName))
{
var layer = psd.Layers[0];
if (!IsLayerIsBackground(layer))
{
throw new Exception("Layer is not Background");
}
// Check if after the save layer stays background
var outputBackgroundPath = "output.psd";
psd.Save(outputBackgroundPath, new PsdOptions());
}
// In this case input image hasn't background layer
sourceFileName = "NotBackground.psd";
using (var psd = (PsdImage)Image.Load(sourceFileName))
{
var layer = psd.Layers[0];
if (IsLayerIsBackground(layer))
{
throw new Exception("Layer must not be Background at the start");
}
// We can make bakground
MakeLayerToBeBackground(layer);
if (!IsLayerIsBackground(layer))
{
throw new Exception("Layer is not Background");
}
// Check if after the save layer became the background layer
var outputBackgroundPath = "outputCreatedBackground.psd";
psd.Save(outputBackgroundPath, new PsdOptions());
}
Thanks Adnan.Ahmad ,
This code using Background Layer created from PSD image.
thank you so much…
yeah sure …