Module Image :: Class Image
[hide private]
[frames] | no frames]

Class Image

source code

The Image object

This object gives access to Images in Blender.

Instance Methods [hide private]
string
getName()
Get the name of this Image object.
source code
string
getFilename()
Get the filename of the image file loaded into this Image object.
source code
list of 2 ints
getSize()
Get the [width, height] dimensions (in pixels) of this image.
source code
int
getDepth()
Get the pixel depth of this image.
source code
list of 4 floats
getPixelHDR(x, y)
Get the the colors of the current pixel in the form [r,g,b,a].
source code
list of 4 floats
getPixelF(x, y)
Get the the colors of the current pixel in the form [r,g,b,a].
source code
list of 4 ints
getPixelI(x, y)
Get the the colors of the current pixel in the form [r,g,b,a].
source code
list of 2 ints
getMaxXY()
Get the x & y size for the image.
source code
list of 2 ints
getMinXY()
Get the x & y origin for the image.
source code
int
getXRep()
Get the number of repetitions in the x (horizontal) axis for this Image.
source code
int
getYRep()
Get the number of repetitions in the y (vertical) axis for this Image.
source code
int
getBindCode()
Get the Image's bindcode.
source code
int
getStart()
Get the Image's start frame.
source code
int
getEnd()
Get the Image's end frame.
source code
int
getSpeed()
Get the Image's speed (fps).
source code
 
reload()
Reloads this image from the filesystem.
source code
 
updateDisplay()
Update the display image from the floating point buffer (if it exists)
source code
int
glLoad()
Load this image's data into OpenGL texture memory, if it is not already loaded (image.bindcode is 0 if it is not loaded yet).
source code
 
glFree()
Delete this image's data from OpenGL texture memory, only (the image itself is not removed from Blender's memory).
source code
 
setName(name)
Set the name of this Image object.
source code
 
setFilename(name)
Change the filename of this Image object.
source code
 
setXRep(xrep)
Texture tiling: set the number of x repetitions for this Image.
source code
 
setYRep(yrep)
Texture tiling: set the number of y repetitions for this Image.
source code
 
setStart(start)
Get the Image's start frame.
source code
 
setEnd(end)
Set the Image's end frame.
source code
 
setSpeed(speed)
Set the Image's speed (fps).
source code
none
setPixelHDR(x, y, (r, g, b, a))
Set the the colors of the current pixel in the form [r,g,b,a].
source code
none
setPixelF(x, y, (r, g, b, a))
Set the the colors of the current pixel in the form [r,g,b,a].
source code
none
setPixelI(x, y, (r, g, b, a))
Set the the colors of the current pixel in the form [r,g,b,a].
source code
 
save()
Saves the current image to filename
source code
none
pack()
Packs the image into the current blend file.
source code
none
unpack(mode)
Unpacks the image to the images filename.
source code
bool
makeCurrent()
Set the currently displayed Image from Blenders UV/Image window.
source code
Instance Variables [hide private]
boolean antialias
enable or disable the antialias option for this image.
int bindcode
Texture's bind code (readonly).
bool clampX
When true the image will not tile horizontally.
bool clampY
When true the image will not tile vertically.
int depth
The pixel depth of the image, read only.
int end
Texture's animation end frame [0, 128].
bool fakeUser
When set to True, this datablock wont be removed, even if nothing is using it.
boolean fields
enable or disable the fields option for this image.
boolean fields_odd
enable or disable the odd fields option for this image.
string filename
The filename (path) to the image file loaded into this Image object.
boolean has_data
True when the image has pixel data (readonly).
string or None lib
path to the blend file this datablock is stored in (readonly).
string name
unique name within each blend file.
boolean packed
True when the Texture is packed (readonly).
IDGroup properties
Returns an IDGroup reference to this datablocks's ID Properties.
list size
The [width, height] dimensions of the image (in pixels).
int source
Image source type.
int speed
Texture's animation speed [1, 100].
int start
Texture's animation start frame [0, 128].
bool tag
A temporary tag that to flag data as being used within a loop.
int users
The number of users this datablock has.
int xrep
Texture tiling: the number of repetitions in the x (horizontal) axis.
int yrep
Texture tiling: the number of repetitions in the y (vertical) axis [1, 16].
Method Details [hide private]

getDepth()

source code 

Get the pixel depth of this image. [8,16,24,32,128 for 32bit float images]

Returns: int

getPixelHDR(x, y)

source code 

Get the the colors of the current pixel in the form [r,g,b,a]. For float image types, returned values can be greater then the useual [0.0, 1.0] range. Pixel coordinates are in the range from 0 to N-1. See getMaxXY

Parameters:
  • x (int) - the x coordinate of pixel.
  • y (int) - the y coordinate of pixel.
Returns: list of 4 floats
[ r, g, b, a]

getPixelF(x, y)

source code 

Get the the colors of the current pixel in the form [r,g,b,a]. Returned values are floats normalized to 0.0 - 1.0. Pixel coordinates are in the range from 0 to N-1. See getMaxXY

Parameters:
  • x (int) - the x coordinate of pixel.
  • y (int) - the y coordinate of pixel.
Returns: list of 4 floats
[ r, g, b, a]

getPixelI(x, y)

source code 

Get the the colors of the current pixel in the form [r,g,b,a]. Returned values are ints normalized to 0 - 255. Pixel coordinates are in the range from 0 to N-1. See getMaxXY

Parameters:
  • x (int) - the x coordinate of pixel.
  • y (int) - the y coordinate of pixel.
Returns: list of 4 ints
[ r, g, b, a]

getMaxXY()

source code 

Get the x & y size for the image. Image coordinates range from 0 to size-1.

Returns: list of 2 ints
[x, y]

getMinXY()

source code 

Get the x & y origin for the image. Image coordinates range from 0 to size-1.

Returns: list of 2 ints
[x, y]

getXRep()

source code 

Get the number of repetitions in the x (horizontal) axis for this Image. This is for texture tiling.

Returns: int

getYRep()

source code 

Get the number of repetitions in the y (vertical) axis for this Image. This is for texture tiling.

Returns: int

getBindCode()

source code 

Get the Image's bindcode. This is for texture loading using BGL calls. See, for example, BGL.glBindTexture and glLoad.

Returns: int

getStart()

source code 

Get the Image's start frame. Used for animated textures.

Returns: int

getEnd()

source code 

Get the Image's end frame. Used for animated textures.

Returns: int

getSpeed()

source code 

Get the Image's speed (fps). Used for animated textures.

Returns: int

reload()

source code 

Reloads this image from the filesystem. If used within a loop you need to redraw the Window to see the change in the image, e.g. with Window.RedrawAll().

Returns:
None

Warning: if the image file is corrupt or still being written, it will be replaced by a blank image in Blender, but no error will be returned.

updateDisplay()

source code 

Update the display image from the floating point buffer (if it exists)

Returns:
None

glLoad()

source code 

Load this image's data into OpenGL texture memory, if it is not already loaded (image.bindcode is 0 if it is not loaded yet).

Returns: int
the texture's bind code.

Note: Usually you don't need to call this method. It is only necessary if you want to draw textured objects in the Scripts window and the image's bind code is zero at that moment, otherwise Blender itself can take care of binding / unbinding textures. Calling this method for an image with nonzero bind code simply returns the image's bind code value (see getBindCode).

glFree()

source code 

Delete this image's data from OpenGL texture memory, only (the image itself is not removed from Blender's memory). Internally, glDeleteTextures (see BGL.glDeleteTextures) is used, but this method also updates Blender's Image object so that its bind code is set to 0. See also Image.glLoad, Image.getBindCode.

setName(name)

source code 

Set the name of this Image object.

Parameters:
  • name (string) - The new name.

setFilename(name)

source code 

Change the filename of this Image object.

Parameters:
  • name (string) - The new full filename.

Warning: use this with caution and note that the filename is truncated if larger than 160 characters.

setXRep(xrep)

source code 

Texture tiling: set the number of x repetitions for this Image.

Parameters:
  • xrep (int) - The new value in [1, 16].

setYRep(yrep)

source code 

Texture tiling: set the number of y repetitions for this Image.

Parameters:
  • yrep (int) - The new value in [1, 16].

setStart(start)

source code 

Get the Image's start frame. Used for animated textures.

Parameters:
  • start (int) - The new value in [0, 128].

setEnd(end)

source code 

Set the Image's end frame. Used for animated textures.

Parameters:
  • end (int) - The new value in [0, 128].

setSpeed(speed)

source code 

Set the Image's speed (fps). Used for animated textures.

Parameters:
  • speed (int) - The new value in [1, 100].

setPixelHDR(x, y, (r, g, b, a))

source code 

Set the the colors of the current pixel in the form [r,g,b,a]. For float image types, returned values can be greater then the useual [0.0, 1.0] range. Pixel coordinates are in the range from 0 to N-1. See getMaxXY

Parameters:
  • a (float)
  • b (float)
  • g (float)
  • r (float)
  • y (int)
  • x (int)
Returns: none
nothing

setPixelF(x, y, (r, g, b, a))

source code 

Set the the colors of the current pixel in the form [r,g,b,a]. Color values must be floats in the range 0.0 - 1.0. Pixel coordinates are in the range from 0 to N-1. See getMaxXY

Parameters:
  • a (float)
  • b (float)
  • g (float)
  • r (float)
  • y (int)
  • x (int)
Returns: none
nothing

setPixelI(x, y, (r, g, b, a))

source code 

Set the the colors of the current pixel in the form [r,g,b,a]. Color values must be ints in the range 0 - 255. Pixel coordinates are in the range from 0 to N-1. See getMaxXY

Parameters:
  • a (int)
  • b (int)
  • g (int)
  • r (int)
  • y (int)
  • x (int)
Returns: none
nothing

save()

source code 

Saves the current image to filename

Returns:
None
Notes:
  • Saving to a directory that doent exist will raise an error.
  • Saving a packed image will make a unique (numbered) name if the file alredy exists. Remove the file first to be sure it will not be renamed.

pack()

source code 

Packs the image into the current blend file.

Since 2.44 new images without valid filenames can be packed.

If the image is alredy packed, it will be repacked.

Returns: none
nothing

unpack(mode)

source code 

Unpacks the image to the images filename.

Parameters:
Returns: none
nothing

Note: An error will be raised if the image is not packed or the filename path does not exist.

makeCurrent()

source code 

Set the currently displayed Image from Blenders UV/Image window. When multiple images are displayed, the last active UV/Image windows image is used.

Returns: bool
True if the current image could be set, if no window was available, return False.

Warning: Deprecated, set bpy.data.images.active = image instead.


Instance Variable Details [hide private]

depth

The pixel depth of the image, read only. [8, 16, 18, 24, 32, 128 (for 32bit float color channels)]
Type:
int

fakeUser

When set to True, this datablock wont be removed, even if nothing is using it. All data has this disabled by default except for Actions.
Type:
bool

lib

path to the blend file this datablock is stored in (readonly).

lib will be None unless you are using external blend files with (File, Append/Link)

Note: the path may be relative, to get the full path use Blender.sys.expandpath

Type:
string or None

name

unique name within each blend file.

The name is case sensitive and 21 characters maximum length.

Note: a blend file may have naming collisions when external library data is used, be sure to check the value of lib.

Note: Setting a value longer then 21 characters will be shortened

Type:
string

source

Image source type. See the Sources dictionary .
Type:
int

tag

A temporary tag that to flag data as being used within a loop. always set all tags to True or False before using since blender uses this flag for its own internal operations.
Type:
bool

users

The number of users this datablock has. (readonly) Zero user datablocks are de-allocated after reloading and saving.
Type:
int

xrep

Texture tiling: the number of repetitions in the x (horizontal) axis. [1, 16].
Type:
int