# NodeBox

Create visual output with Python programming code
Home Download Reference Tutorial Library Gallery About

# photobot.Layer.copy()

## Syntax

canvas.layers[i].copy()

## Description

Returns a copy of layer i on the canvas. This is different from the Layer.duplicate() command, which duplicates the layer as a new layer on the canvas. The Layer.copy() command returns a copy of the layer object, that can be added to a different canvas with the Canvas.layer() command.

## Example

This example shows how you can automate tasks by creating functions that return a processed layer copy. The brighten() function brightens any image you pass to it, and returns a layer copy. More complex functions could manipulate an image in this way without having to retype the same manipulations over and over.

    photobot = ximport("photobot")

    def brighten(image):
      canvas = photobot.canvas(100,100)
      canvas.layer(image)
      canvas.layers[1].brightness(1.2)
      return canvas.layers[1].copy()

    canvas = photobot.canvas(100,100)
    canvas.layer(brighten("robot.jpg"))
    canvas.layer(brighten("penguin.jpg"))