Free Support Forum - aspose.com

How do set the particular layer as default auto for Psd image

How to select the particular layer is defaut auto select.

Three layer are shown but particular of layer[2] only select,
it’s possible or not?

@veerakarthik,

I have observed your requirements and regret to share that at present the requested support is unavailable in API. An issue with ID PSDNET-512 has been created in our issue tracking system to provide the requested support. This thread has been linked with the issue so that you may be notified once the support will be available.

1 Like

Hi,
when we psd image first open it, the Layer that is selected/highlighted is the one called “Top layer”. Is it possible to select/highlight “particular layer” instead?

@veerakarthik,

Thank you for sharing the additional information. I have associated the information in our issue tracking system and will get back to you with feedback as soon as the feature will be available.

1 Like

HI,

I have a psd file with three layers like: layer1, layer2 & layer3

When i open that psd file in adobe photoshop the “Layer2” will be Selected/Highlighted by default instead of Highlighting the Layer3 .

How can i achive this?

@veerakarthik,

I have observed your requirements and this is continuation of your previous queries. I have updated the issue description and will share the feedback with you as soon as the issue will be addressed.

Ok thank you sir…

Hi,

Default Highlighting layers.
Any updates on an issue with ID “PSDNET-512”

@veerakarthik,

Can you please try to use following sample code on your end and share feedback with us if there is still an issue.

 private LyidResource GetLyidResource(Layer layer)
        {
            var resourceCount = layer.Resources.Length;
            for (int i = 0; i < resourceCount; i++)
            {
                if (layer.Resources[i] is LyidResource)
                {
                    return (LyidResource)layer.Resources[i];
                }
            }

            return null;
        }

        private TImageResource GetImageSectionResource<TImageResource>(PsdImage image) where TImageResource : ResourceBlock
        { 
            var resourceCount = image.ImageResources.Length;
            for (int i = 0; i < resourceCount; i++)
            {
                if (image.ImageResources[i] is TImageResource)
                {
                    return (TImageResource)image.ImageResources[i];
                }
            }

            return null;
        }

            string sourceFileName = "ActiveLayerEqual2.psd";
            string outputFileName = "output.psd";

            using (PsdImage image = (PsdImage)Image.Load(sourceFileName))
            {
                var layerStateResource = GetImageSectionResource<LayerStateInformationResource>(image);
                var selectionResource = GetImageSectionResource<LayerSelectionIdsResource>(image);

                short indexOfLayerToSelect = 2;
                var layerToSelect = image.Layers[indexOfLayerToSelect];
                var layerId = GetLyidResource(layerToSelect).Value;

                layerStateResource.LayerIndex = indexOfLayerToSelect;
                selectionResource.LayerIds = new int[] { layerId };

                image.Save(outputFileName, new PsdOptions(image));
            }

Hi, Ahmad,

      Layer Higlighted/Selected are working fine.

Thank you so much…

@veerakarthik,

Thank you for sharing the feedback.