6 converts a layer to an array. 7 @param layer a gimp layer 8 @param dtype the requested output type (optional) 9 @return a numpy array representing the layer (height x width x channels) 11 r = layer.get_pixel_rgn(0, 0, layer.width, layer.height,
False,
False)
12 m = numpy.reshape(numpy.fromstring(r[:,:],dtype=numpy.uint8),(r.h,r.w,r.bpp))
14 return numpy.array(m, dtype=dtype)
20 copies an array into a layer. (image/layer size must match) 21 @param layer a gimp layer 22 @param data a numpy array representing the layer (height x width x channels; must match the layers' size/channels). The data is converted into uint8. 24 r = layer.get_pixel_rgn(0, 0, layer.width, layer.height,
False,
False)
25 data8 = numpy.array(data[:],dtype=numpy.uint8);
26 r[:,:] = data8.tostring()
def copy_array_into_layer(data, layer)
copies an array into a layer.
def layer2array(layer, dtype=None)
converts a layer to an array.