'Render this image layer.
Given a configuration object, starting image, and coordinate,
return an output image with the contents of this image layer.'

def render(self, config, input_rgba, coord):

    (has_layer, has_color, has_mask) = (False, False, False)
    output_rgba = [chan.copy() for chan in input_rgba]
    if self.layername:
        layer = config.layers[self.layername]
        (mime, body) = TileStache.getTile(layer, coord, 'png')
        layer_img = Image.open(StringIO(body)).convert('RGBA')
        layer_rgba = _img2rgba(layer_img)
        has_layer = True
    if self.maskname:
        layer = config.layers[self.maskname]
        (mime, body) = TileStache.getTile(layer, coord, 'png')
        mask_img = Image.open(StringIO(body)).convert('L')
        mask_chan = (_img2arr(mask_img).astype(numpy.float32) / 255.0)
        has_mask = True
    if self.colorname:
        color = make_color(self.colorname)
        color_rgba = [(numpy.zeros(output_rgba[0].shape, numpy.float32) + (band / 255.0)) for band in color]
        has_color = True
    if has_layer:
        layer_rgba = apply_adjustments(layer_rgba, self.adjustments)
    if (has_layer and has_color and has_mask):
        raise KnownUnknown(("You    can't    specify    src,    color    and    mask    together    in    a    Composite    Layer:    %s,    %s,    %s" % (repr(self.layername), repr(self.colorname), repr(self.maskname))))
    elif (has_layer and has_color):
        output_rgba = blend_images(output_rgba, color_rgba[:3], color_rgba[3], self.opacity, self.blendmode)
        output_rgba = blend_images(output_rgba, layer_rgba[:3], layer_rgba[3], self.opacity, self.blendmode)
    elif (has_layer and has_mask):
        layermask_chan = (layer_rgba[3] * mask_chan)
        output_rgba = blend_images(output_rgba, layer_rgba[:3], layermask_chan, self.opacity, self.blendmode)
    elif (has_color and has_mask):
        output_rgba = blend_images(output_rgba, color_rgba[:3], mask_chan, self.opacity, self.blendmode)
    elif has_layer:
        output_rgba = blend_images(output_rgba, layer_rgba[:3], layer_rgba[3], self.opacity, self.blendmode)
    elif has_color:
        output_rgba = blend_images(output_rgba, color_rgba[:3], color_rgba[3], self.opacity, self.blendmode)
    elif has_mask:
        raise KnownUnknown(('You    have    to    provide    more    than    just    a    mask    to    Composite    Layer:    %s' % repr(self.maskname)))
    else:
        raise KnownUnknown('You    have    to    provide    at    least    some    combination    of    src,    color    and    mask    to    Composite    Layer')
    return output_rgba
