Create Anaglyph (GIMP Plugin)
gimpfu_numpy_converter Namespace Reference

Functions

def layer2array (layer, dtype=None)
 converts a layer to an array. More...
 
def copy_array_into_layer (data, layer)
 copies an array into a layer. More...
 

Function Documentation

def gimpfu_numpy_converter.copy_array_into_layer (   data,
  layer 
)

copies an array into a layer.

(image/layer size must match)

Parameters
layera gimp layer
dataa numpy array representing the layer (height x width x channels; must match the layers' size/channels). The data is converted into uint8.

Definition at line 18 of file gimpfu_numpy_converter.py.

18 def copy_array_into_layer(data, layer):
19  """!
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.
23  """
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()
27 
28 
29 
def copy_array_into_layer(data, layer)
copies an array into a layer.
def gimpfu_numpy_converter.layer2array (   layer,
  dtype = None 
)

converts a layer to an array.

Parameters
layera gimp layer
dtypethe requested output type (optional)
Returns
a numpy array representing the layer (height x width x channels)

Definition at line 4 of file gimpfu_numpy_converter.py.

4 def layer2array(layer,dtype=None):
5  """!
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)
10  """
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))
13  if dtype!=None:
14  return numpy.array(m, dtype=dtype)
15  else:
16  return m
17 
def layer2array(layer, dtype=None)
converts a layer to an array.