< GeeXLab Reference Guide />
> Back to Reference Guide Index
gh_imagemagick library
Description
gh_imagemagick is the module that manages ImageMagick functions. ImageMagick allows to create, edit, compose, or convert bitmap images, read and write images in a variety of formats (over 200) including PNG, JPEG, JPEG-2000, GIF, TIFF, DPX, EXR, WebP, Postscript, PDF, and SVG....
Number of functions: 39
- gh_imagemagick.file_convert ()
- gh_imagemagick.file_crop ()
- gh_imagemagick.file_exif_get_num_properties ()
- gh_imagemagick.file_exif_get_property ()
- gh_imagemagick.file_exif_to_log ()
- gh_imagemagick.file_ping ()
- gh_imagemagick.file_resize ()
- gh_imagemagick.texture_auto_level ()
- gh_imagemagick.texture_blur ()
- gh_imagemagick.texture_charcoal ()
- gh_imagemagick.texture_cleanup ()
- gh_imagemagick.texture_constitute ()
- gh_imagemagick.texture_create_from_buffer ()
- gh_imagemagick.texture_create_from_file ()
- gh_imagemagick.texture_create_from_zip_file ()
- gh_imagemagick.texture_crop ()
- gh_imagemagick.texture_decipher ()
- gh_imagemagick.texture_edge ()
- gh_imagemagick.texture_emboss ()
- gh_imagemagick.texture_encipher ()
- gh_imagemagick.texture_flip ()
- gh_imagemagick.texture_flop ()
- gh_imagemagick.texture_gaussian_blur ()
- gh_imagemagick.texture_motion_blur ()
- gh_imagemagick.texture_negate ()
- gh_imagemagick.texture_oil_paint ()
- gh_imagemagick.texture_posterize ()
- gh_imagemagick.texture_quantize ()
- gh_imagemagick.texture_read ()
- gh_imagemagick.texture_resize ()
- gh_imagemagick.texture_sepia ()
- gh_imagemagick.texture_sharpen ()
- gh_imagemagick.texture_sketch ()
- gh_imagemagick.texture_solarize ()
- gh_imagemagick.texture_swirl ()
- gh_imagemagick.texture_transpose ()
- gh_imagemagick.texture_update ()
- gh_imagemagick.texture_wave ()
- gh_imagemagick.texture_write ()
file_convert
Description
Converts an image file (new format).
Syntax
ret = gh_imagemagick.file_convert(
src_filename,
dst_filename
)
Languages
Parameters
- src_filename [STRING]: absolute path of the source image file
- dst_filename [STRING]: absolute path of the destination image file
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
ret = gh_imagemagick.file_convert(src_filename, dst_filename)
file_crop
Description
Crops an image file.
Syntax
ret = gh_imagemagick.file_crop(
src_filename,
dst_filename,
x, y, width, height
)
Languages
Parameters
- src_filename [STRING]: absolute path of the source image file
- dst_filename [STRING]: absolute path of the destination image file
- x, y, width, height [INTEGER]: crop rectangle
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
ret = gh_imagemagick.file_crop(src_filename, dst_filename, x, y, width, height)
file_exif_get_num_properties
Description
Gets the number of EXIF properties of an image.
Syntax
num_exif = gh_imagemagick.file_exif_get_num_properties(
filename
)
Languages
Parameters
- filename [STRING]: absolute path of the image file
Return Values
- num_exif [INTEGER]: number of EXIF properties
Code sample
num_exif = gh_imagemagick.file_exif_get_num_properties(filename)
file_exif_get_property
Description
Gets a particular EXIF property of an image.
Syntax
prop_name, prop_value = gh_imagemagick.file_exif_get_property(
filename,
prop_index
)
Languages
Parameters
- filename [STRING]: absolute path of the image file
- prop_index [INTEGER]: property index
Return Values
- prop_name, prop_value [STRING]: property name and value
Code sample
prop_name, prop_value = gh_imagemagick.file_exif_get_property(filename, prop_index)
file_exif_to_log
Description
Writes to the log all EXIF data of an image.
Syntax
gh_imagemagick.file_exif_to_log(
filename
)
Languages
Parameters
- filename [STRING]: absolute path of the image file
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.file_exif_to_log(filename)
file_ping
Description
Returns simple information (size and format) about an image file without loading it in memory.
Syntax
format, width, height = gh_imagemagick.file_ping(
filename
)
Languages
Parameters
- filename [STRING]: absolute path of the image file
Return Values
- format [STRING]: image format (jpg, png, etc.)
- width, height [INTEGER]: size of the image
Code sample
w, h, format = gh_imagemagick.file_ping(filename)
file_resize
Description
Resizes an image file.
Syntax
ret = gh_imagemagick.file_resize(
src_filename,
dst_filename,
width, height
)
Languages
Parameters
- src_filename [STRING]: absolute path of the source image file
- dst_filename [STRING]: absolute path of the destination image file
- width, height [INTEGER]: new size
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
ret = gh_imagemagick.file_resize(src_filename, dst_filename, 640, 480)
texture_auto_level
Description
Applies an auto level effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_auto_level(
tex_id
)
Languages
Parameters
- tex_id [ID]: texture identifier
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_auto_level(tex_id)
gh_imagemagick.texture_update(tex_id)
texture_blur
Description
Applies a blur effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_blur(
tex_id,
radius, sigma
)
Languages
Parameters
- tex_id [ID]: texture identifier
- radius, sigma [REAL]: effect params.
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_blur(tex_id, radius, sigma)
gh_imagemagick.texture_update(tex_id)
texture_charcoal
Description
Applies a charcoal effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_charcoal(
tex_id,
radius, sigma
)
Languages
Parameters
- tex_id [ID]: texture identifier
- radius, sigma [REAL]: effect params.
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_charcoal(tex_id, radius, sigma)
gh_imagemagick.texture_update(tex_id)
texture_cleanup
Description
Frees all ImageMagick resources allocated by the texture. Should be called in a TERMINATE script.
Syntax
gh_imagemagick.texture_cleanup(
tex_id
)
Languages
Parameters
- tex_id [ID]: texture identifier
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_cleanup(tex_id)
texture_constitute
Description
Updates the texture to be ImageMagick-compatible. The texture can be used with other imagemagick functions.
Syntax
ret = gh_imagemagick.texture_constitute(
tex_id
)
Languages
Parameters
- tex_id [ID]: texture identifier
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
ret = gh_imagemagick.texture_constitute(tex_id)
texture_create_from_buffer
Description
Creates a texture object from a memory buffer.
Syntax
tex_id = gh_imagemagick.texture_create_from_buffer(
buff_ptr,
buff_size,
pf,
gen_mipmaps,
free_cpu_memory,
upload_to_gpu
)
Languages
Parameters
- buff_ptr [POINTER]: pointer to the buffer
- buff_size [INTEGER]: size of the buffer in bytes
- pf [ENUM]: pixel format. See all PF_xxx values.
- gen_mipmaps [BOOLEAN]: mipmap generation: 1 (enabled) or 0 (disabled). Currently, works with OpenGL renderer only.
- free_cpu_memory [BOOLEAN]: frees the CPU memory after loading in GPU memory: 1 (true) or 0 (false)
- upload_to_gpu [BOOLEAN]: uploads the pixmap into GPU memory: 1 (true) or 0 (false)
Return Values
- tex_id [ID]: texture identifier
Code sample
PF_U8_RGB = 1
PF_U8_BGR = 2
PF_U8_RGBA = 3
PF_U8_BGRA = 4
PF_F32_RGB = 5
PF_F32_RGBA = 6
PF_F32_R = 7
PF_U8_R = 11
PF_U8_RG = 12
local PF_U8_RGBA = 3
local upload_to_gpu = 1
local gen_mipmaps = 1
local free_cpu_memory = 1
filename = demo_dir .. "assets/image.jpg"
buffer, buffer_size = gh_utils.file_buffer_create(filename)
tex_id = gh_imagemagick.texture_create_from_buffer(buffer, buffer_size, PF_U8_RGBA, gen_mipmaps, free_cpu_memory, upload_to_gpu)
gh_utils.file_buffer_kill(buffer)
texture_create_from_file
Description
Creates a texture object from an image file.
Syntax
tex_id = gh_imagemagick.texture_create_from_file(
filename,
pf,
gen_mipmaps,
free_cpu_memory,
upload_to_gpu
)
Languages
Parameters
- filename [STRING]: absolute path of the image file
- pf [ENUM]: pixel format. See all PF_xxx values.
- gen_mipmaps [BOOLEAN]: mipmap generation: 1 (enabled) or 0 (disabled). Currently, works with OpenGL renderer only.
- free_cpu_memory [BOOLEAN]: frees the CPU memory after loading in GPU memory: 1 (true) or 0 (false)
- upload_to_gpu [BOOLEAN]: uploads the pixmap into GPU memory: 1 (true) or 0 (false)
Return Values
- tex_id [ID]: texture identifier
Code sample
PF_U8_RGB = 1
PF_U8_BGR = 2
PF_U8_RGBA = 3
PF_U8_BGRA = 4
PF_F32_RGB = 5
PF_F32_RGBA = 6
PF_F32_R = 7
PF_U8_R = 11
PF_U8_RG = 12
tex_id = gh_imagemagick.texture_create_from_file(filename, PF_U8_RGBA, gen_mipmaps, free_cpu_memory, upload_to_gpu)
texture_create_from_zip_file
Description
Creates a texture object from an image file stored in a zip archive.
Syntax
tex_id = gh_imagemagick.texture_create_from_zip_file(
zip_filename,
filename,
pf,
gen_mipmaps,
free_cpu_memory,
upload_to_gpu
)
Languages
Parameters
- zip_filename [STRING]: absolute path of the zip file
- filename [STRING]: image file in the zip archive
- pf [ENUM]: pixel format. See all PF_xxx values.
- gen_mipmaps [BOOLEAN]: mipmap generation: 1 (enabled) or 0 (disabled). Currently, works with OpenGL renderer only.
- free_cpu_memory [BOOLEAN]: frees the CPU memory after loading in GPU memory: 1 (true) or 0 (false)
- upload_to_gpu [BOOLEAN]: uploads the pixmap into GPU memory: 1 (true) or 0 (false)
Return Values
- tex_id [ID]: texture identifier
Code sample
PF_U8_RGB = 1
PF_U8_BGR = 2
PF_U8_RGBA = 3
PF_U8_BGRA = 4
PF_F32_RGB = 5
PF_F32_RGBA = 6
PF_F32_R = 7
PF_U8_R = 11
PF_U8_RG = 12
local PF_U8_RGBA = 3
local upload_to_gpu = 1
local gen_mipmaps = 1
local free_cpu_memory = 1
local demo_dir = gh_utils.get_demo_dir()
zip_filename = demo_dir .. "demo.zip"
filename = "assets/image.jpg"
tex_id = gh_imagemagick.texture_create_from_zip_file(zip_filename, filename, PF_U8_RGBA, gen_mipmaps, free_cpu_memory, upload_to_gpu)
texture_crop
Description
Applies a crop effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_crop(
tex_id,
x, y, width, height
)
Languages
Parameters
- tex_id [ID]: texture identifier
- x, y, width, height [INTEGER]: cropping region
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_crop(tex_id, x, y, width, height)
gh_imagemagick.texture_update(tex_id)
texture_decipher
Description
Applies a decipher effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_decipher(
tex_id,
passphrase
)
Languages
Parameters
- tex_id [ID]: texture identifier
- passphrase [STRING]: effect param.
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_decipher(tex_id, "geexlab")
gh_imagemagick.texture_update(tex_id)
texture_edge
Description
Applies an edge effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_edge(
tex_id,
radius
)
Languages
Parameters
- tex_id [ID]: texture identifier
- radius [REAL]: effect param.
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_edge(tex_id, radius)
gh_imagemagick.texture_update(tex_id)
texture_emboss
Description
Applies an emboss effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_emboss(
tex_id,
radius, sigma
)
Languages
Parameters
- tex_id [ID]: texture identifier
- radius, sigma [REAL]: effect params.
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_emboss(tex_id, radius, sigma)
gh_imagemagick.texture_update(tex_id)
texture_encipher
Description
Applies an encipher effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_encipher(
tex_id,
passphrase
)
Languages
Parameters
- tex_id [ID]: texture identifier
- passphrase [STRING]: effect param.
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_encipher(tex_id, "geexlab")
gh_imagemagick.texture_update(tex_id)
texture_flip
Description
Applies a flip effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_flip(
tex_id
)
Languages
Parameters
- tex_id [ID]: texture identifier
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_flip(tex_id)
gh_imagemagick.texture_update(tex_id)
texture_flop
Description
Applies a flop effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_flop(
tex_id
)
Languages
Parameters
- tex_id [ID]: texture identifier
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_flop(tex_id)
gh_imagemagick.texture_update(tex_id)
texture_gaussian_blur
Description
Applies a motion blur effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_gaussian_blur(
tex_id,
radius, sigma
)
Languages
Parameters
- tex_id [ID]: texture identifier
- radius, sigma [REAL]: effect params.
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_gaussian_blur(tex_id, radius, sigma)
gh_imagemagick.texture_update(tex_id)
texture_motion_blur
Description
Applies a motion blur effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_motion_blur(
tex_id,
radius, sigma, angle
)
Languages
Parameters
- tex_id [ID]: texture identifier
- radius, sigma, angle [REAL]: effect params.
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_motion_blur(tex_id, radius, sigma, angle)
gh_imagemagick.texture_update(tex_id)
texture_negate
Description
Applies a negate effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_negate(
tex_id,
only_negate_grayscale_pixels
)
Languages
Parameters
- tex_id [ID]: texture identifier
- only_negate_grayscale_pixels [BOOLEAN]: only negate grayscale pixels: 1 (true) or 0 (false)
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_negate(tex_id, 0)
gh_imagemagick.texture_update(tex_id)
texture_oil_paint
Description
Applies a oil paint effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_oil_paint(
tex_id,
radius, sigma
)
Languages
Parameters
- tex_id [ID]: texture identifier
- radius, sigma [REAL]: effect params.
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_oil_paint(tex_id, radius, sigma)
gh_imagemagick.texture_update(tex_id)
texture_posterize
Description
Applies a posterize effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_posterize(
tex_id,
num_colors,
dither_method_type
)
Languages
Parameters
- tex_id [ID]: texture identifier
- num_colors [INTEGER]: effect params.
- dither_method_type [ENUM]: dithering method
Return Values
This function has no return value(s).
Code sample
dither_method_type:
"none"
"riemersma"
"floydsteinberg"
num_colors = 4
dither_method_type = "none"
gh_imagemagick.texture_posterize(tex_id, num_colors, dither_method_type)
gh_imagemagick.texture_update(tex_id)
texture_quantize
Description
Applies a quantize effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_quantize(
tex_id,
num_colors,
color_space_type,
treedepth,
dither_method_type
)
Languages
Parameters
- tex_id [ID]: texture identifier
- num_colors [INTEGER]: number of colors
- color_space_type [ENUM]: color space
- treedepth [INTEGER]: effect params.
- dither_method_type [ENUM]: dithering method
Return Values
This function has no return value(s).
Code sample
color_space_type:
'cmy'
'cmyk'
'gray'
'hsb'
'hsl'
'luv'
'rgb'
'srgb'
'xyz'
'ycbcr'
'yuv'
dither_method_type:
'none'
'riemersma'
'floydsteinberg'
num_colors = 4
color_space_type = "srgb"
treedepth = 1
dither_method_type = "none"
gh_imagemagick.texture_quantize(tex_id, num_colors, color_space_type, treedepth, dither_method_type)
gh_imagemagick.texture_update(tex_id)
texture_read
Description
Reads the content of an image file and stores it in an existing texture.
Syntax
gh_imagemagick.texture_read(
tex_id,
filename,
pf
)
Languages
Parameters
- tex_id [ID]: texture identifier
- filename [STRING]: absolute path of the image file
- pf [ENUM]: pixel format. See all PF_xxx values.
Return Values
This function has no return value(s).
Code sample
PF_U8_RGB = 1
PF_U8_BGR = 2
PF_U8_RGBA = 3
PF_U8_BGRA = 4
PF_F32_RGB = 5
PF_F32_RGBA = 6
PF_F32_R = 7
PF_U8_R = 11
PF_U8_RG = 12
gh_imagemagick.texture_read(tex_id, filename, PF_U8_RGBA)
texture_resize
Description
Applies a resize effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_resize(
tex_id,
width, height
)
Languages
Parameters
- tex_id [ID]: texture identifier
- width, height [INTEGER]: new size
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_resize(tex_id, width, height)
gh_imagemagick.texture_update(tex_id)
texture_sepia
Description
Applies a sepia effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_sepia(
tex_id,
threshold
)
Languages
Parameters
- tex_id [ID]: texture identifier
- threshold [REAL]: effect param.
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_sepia(tex_id, threshold)
gh_imagemagick.texture_update(tex_id)
texture_sharpen
Description
Applies a sharpen effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_sharpen(
tex_id,
radius, sigma
)
Languages
Parameters
- tex_id [ID]: texture identifier
- radius, sigma [REAL]: effect params.
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_sharpen(tex_id, radius, sigma)
gh_imagemagick.texture_update(tex_id)
texture_sketch
Description
Applies a sketch effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_sketch(
tex_id,
radius, sigma, angle
)
Languages
Parameters
- tex_id [ID]: texture identifier
- radius, sigma, angle [REAL]: effect params.
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_sketch(tex_id, radius, sigma, angle)
gh_imagemagick.texture_update(tex_id)
texture_solarize
Description
Applies a solarize effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_solarize(
tex_id,
threshold
)
Languages
Parameters
- tex_id [ID]: texture identifier
- threshold [REAL]: effect param.
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_solarize(tex_id)
gh_imagemagick.texture_update(tex_id)
texture_swirl
Description
Applies a swirl effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_swirl(
tex_id,
degrees,
interpolation_method
)
Languages
Parameters
- tex_id [ID]: texture identifier
- degrees [REAL]: effect param.
- interpolation_method [ENUM]: interpolation
Return Values
This function has no return value(s).
Code sample
interpolation_method:
'spline'
'nearest'
'triangular_mesh'
'integer_floor'
'catrom'
'blend'
'bilinear'
'background'
'average16'
'average9'
'average4'
gh_imagemagick.texture_swirl(tex_id, degrees, "triangular_mesh")
gh_imagemagick.texture_update(tex_id)
texture_transpose
Description
Applies a transpose effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_transpose(
tex_id
)
Languages
Parameters
- tex_id [ID]: texture identifier
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_transpose(tex_id)
gh_imagemagick.texture_update(tex_id)
texture_update
Description
Updates the texture after ImageMagick operations on it (like cropping, effects, etc.).
Syntax
gh_imagemagick.texture_update(
tex_id
)
Languages
Parameters
- tex_id [ID]: texture identifier
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_update(tex_id)
texture_wave
Description
Applies a wave effect on the ImageMagick data of a texture.
Syntax
gh_imagemagick.texture_wave(
tex_id,
amplitude, wave_length,
interpolation_method
)
Languages
Parameters
- tex_id [ID]: texture identifier
- amplitude, wave_length [REAL]: effect params.
- interpolation_method [ENUM]: interpolation
Return Values
This function has no return value(s).
Code sample
interpolation_method:
'spline'
'nearest'
'triangular_mesh'
'integer_floor'
'catrom'
'blend'
'bilinear'
'background'
'average16'
'average9'
'average4'
gh_imagemagick.texture_wave(tex_id, amplitude, wave_length, "bilinear")
gh_imagemagick.texture_update(tex_id)
texture_write
Description
Writes / saves a texture to a file.
Syntax
gh_imagemagick.texture_write(
tex_id,
filename
)
Languages
Parameters
- tex_id [ID]: texture identifier
- filename [STRING]: absolute path of the image file
Return Values
This function has no return value(s).
Code sample
gh_imagemagick.texture_write(tex_id, filename)
| |