Replace image in psd file

How to find image layer in psd?
How to replace image in psd?

@Dharmpal you can find image layer by name if you know it.

        String filePath = "path/to/your/psd/file.psd";
        PsdImage image = (PsdImage) Image.load(filePath);

        // Find the layer by name
        String layerName = "LayerName";
        Layer foundLayer = null;
        for (Layer layer : image.getLayers()) {
            if (layer.getName().equals(layerName)) {
                foundLayer = layer;
                break;
            }
        }

Or if you need find only Regular Image Layers you can use the following code:

    public static boolean isLayerRegular(Layer layer) 
    {
        return !(layer instanceof AdjustmentLayer ||
                 layer instanceof LayerGroup ||
                 layer instanceof SmartObjectLayer ||
                 layer instanceof ShapeLayer ||
                 layer instanceof TextLayer);
    }

There are many ways to replace layer, for example try this code:

   FileStream stream = new FileStream(filePath, FileMode.Open);
   Layer layer = null;
   layer = new Layer(stream.toInputStream());
   Layer[] layers = psdImage.getLayers();
   layers[3] = layer;
   psdImage.setLayers(layers);