Functions
new
new(name, encoding, width, height, model?) -> int<collection.IMAGE>
- name
string - encoding
int<image.Encoding> - width
int - height
int - model
int<image.ColorModel>
int<collection.IMAGE>
new_filled
new_filled(name, encoding, width, height, color, model?) -> int<collection.IMAGE>
- name
string - encoding
int<image.Encoding> - width
int - height
int - color
struct<image.Color> - model
int<image.ColorModel>
int<collection.IMAGE>
new_random
new_random(name, encoding, width, height, enableAlpha?, model?) -> int<collection.IMAGE>
- name
string - encoding
int<image.Encoding> - width
int - height
int - enableAlpha
bool - model
int<image.ColorModel>
int<collection.IMAGE>
new_empty
new_empty(name, encoding) -> int<collection.IMAGE>
Creates a 1px by 1px gray image.
- name
string - encoding
int<image.Encoding>
int<collection.IMAGE>
remove
remove(id)
Removes the image from the collection. This is a shortcut for collection.collect(collection.IMAGE, id).
- id
int<collection.IMAGE>
name
name(id, name)
- id
int<collection.IMAGE> - name
string- The new name to use for the image, not including the file extension.
name_ext
name_ext(id, options)
- id
int<collection.IMAGE> - options
struct<image.ImageNameOptions>
encoding
encoding(id, encoding)
- id
int<collection.IMAGE> - encoding
int<image.Encoding>
model
model(id) -> int<image.ColorModel>
@blocking
- id
int<collection.IMAGE>
int<image.ColorModel>
size
size(id) -> int, int
@blocking
- id
int<collection.IMAGE>
int- Image width.int- Image height.
crop
crop(id, x1, y1, x2, y2)
Overwrites the image.
- id
int<collection.IMAGE> - x1
int - y1
int - x2
int - y2
int
subimg
subimg(id, name, x1, y1, x2, y2, copy?) -> int<collection.IMAGE>
- id
int<collection.IMAGE> - name
string- Name for the new image. - x1
int - y1
int - x2
int - y2
int - copy
bool
int<collection.IMAGE>
copy
copy(id, name, model) -> int<collection.IMAGE>
- id
int<collection.IMAGE> - name
string - model
int<image.ColorModel>- Use -1 to maintain the color model.
int<collection.IMAGE>
clone
clone(id, src, model)
Clones image src to id with the new model.
- id
int<collection.IMAGE> - src
int<collection.IMAGE> - model
int<image.ColorModel>- Use -1 to maintain the color model.
int<collection.IMAGE>
convert
convert(id, model)
Replaces the image inplace with a new image with the new model.
- id
int<collection.IMAGE> - model
int<image.ColorModel>
refresh
refresh(id)
Shortcut for redrawing the image to guarantee the bounds of the image start at (0,0). This is sometimes needed as thirdparty libraries don't always account for non-zero min bounds.
- id
int<collection.IMAGE>
clear
clear(id)
Resets all pixels to 0,0,0,0.
- id
int<collection.IMAGE>
alpha_set
alpha_set(id, alpha)
This has no effect on gray, gray16, or cmyk images.
- id
int<collection.IMAGE> - alpha
int
pixel
pixel(id, x, y) -> struct<image.ColorRGBA>
@blocking
- id
int<collection.IMAGE> - x
int - y
int
struct<image.ColorRGBA>
pixel_set
pixel_set(id, x, y, color)
- id
int<collection.IMAGE> - x
int - y
int - color
struct<image.Color>
point
point(x?, y?) -> struct<image.Point>
- x
int - y
int
struct<image.Point>
color_hex_to_rgba
color_hex_to_rgba(hex) -> struct<image.ColorRGBA>
- hex
string- Accepts the formats RGBA, RGB, RRGGBBAA, RRGGBB, and an optional prefix of "#", "$", or "0x".
struct<image.ColorRGBA>
color_hex_to_rgba_bgr
color_hex_to_rgba_bgr(hex) -> struct<image.ColorRGBA>
- hex
string- Accepts the formats ABGR, BGR, AABBGGRR, BBGGRR, and an optional prefix of "#", "$", or "0x".
struct<image.ColorRGBA>
color_to_hex
color_to_hex(color, noalpha?, prefix?, lowercase?) -> string
In the format RRGGBBAA or RRGGBB.
- color
struct<image.Color> - noalpha
bool- Set to true to exclude the alpha channel. - prefix
string- Should be "", "#", '$', or "0x". - lowercase
bool- Set to true to use lowercase letters in the hex string.
string
color_to_hex_bgr
color_to_hex_bgr(color, noalpha?, prefix?, lowercase?) -> string
In the format AABBGGRR or BBGGRR.
- color
struct<image.Color> - noalpha
bool- Set to true to exclude the alpha channel. - prefix
string- Should be "", "#", '$', or "0x". - lowercase
bool- Set to true to use lowercase letters in the hex string.
string
color_8bit_to_16bit
color_8bit_to_16bit(c) -> int
- c
int
int
color_16bit_to_8bit
color_16bit_to_8bit(c) -> int
- c
int
int
color_24bit_to_rgba
color_24bit_to_rgba(c) -> struct<image.ColorRGBA>
- c
int
struct<image.ColorRGBA>
color_32bit_to_rgba
color_32bit_to_rgba(c) -> struct<image.ColorRGBA>
- c
int
struct<image.ColorRGBA>
color_to_24bit
color_to_24bit(color) -> int
- color
struct<image.Color>
int
color_to_32bit
color_to_32bit(color) -> int
- color
struct<image.Color>
int
color_rgb
color_rgb(r, g, b) -> struct<image.ColorRGBA>
Alpha channel is set to 255.
- r
int - g
int - b
int
struct<image.ColorRGBA>
color_rgba
color_rgba(r, g, b, a) -> struct<image.ColorRGBA>
- r
int - g
int - b
int - a
int
struct<image.ColorRGBA>
color_hsv
color_hsv(h, s, v) -> struct<image.ColorHSVA>
Alpha channel is set to 255.
- h
int - s
int - v
int
struct<image.ColorHSVA>
color_hsva
color_hsva(h, s, v, a) -> struct<image.ColorHSVA>
- h
int - s
int - v
int - a
int
struct<image.ColorHSVA>
color_hsl
color_hsl(h, s, l) -> struct<image.ColorHSLA>
Alpha channel is set to 255.
- h
int - s
int - l
int
struct<image.ColorHSLA>
color_hsla
color_hsla(h, s, l, a) -> struct<image.ColorHSLA>
- h
int - s
int - l
int - a
int
struct<image.ColorHSLA>
color_alpha
color_alpha(a) -> struct<image.ColorALPHA>
- a
int
struct<image.ColorALPHA>
color_alpha16
color_alpha16(a) -> struct<image.ColorALPHA16>
- a
int
struct<image.ColorALPHA16>
color_gray
color_gray(v) -> struct<image.ColorGRAY>
- v
int
struct<image.ColorGRAY>
color_gray16
color_gray16(v) -> struct<image.ColorGRAY16>
- v
int
struct<image.ColorGRAY16>
color_graya
color_graya(v, a) -> struct<image.ColorGRAYA>
- v
int - a
int
struct<image.ColorGRAYA>
color_graya16
color_graya16(v, a) -> struct<image.ColorGRAYA16>
- v
int - a
int
struct<image.ColorGRAYA16>
color_cmyk
color_cmyk(c, m, y, k) -> struct<image.ColorCMYK>
- c
int - m
int - y
int - k
int
struct<image.ColorCMYK>
color_cmyka
color_cmyka(c, m, y, k, a) -> struct<image.ColorCMYKA>
- c
int - m
int - y
int - k
int - a
int
struct<image.ColorCMYKA>
color_zero
color_zero() -> struct<image.ColorZERO>
struct<image.ColorZERO>
color_to_rgb
color_to_rgb(color) -> struct<image.ColorRGBA>
Alpha is maintained.
- color
struct<image.Color>
struct<image.ColorRGBA>
color_to_hsv
color_to_hsv(color) -> struct<image.ColorHSVA>
Alpha is maintained.
- color
struct<image.Color>
struct<image.ColorHSVA>
color_to_hsl
color_to_hsl(color) -> struct<image.ColorHSLA>
Alpha is maintained.
- color
struct<image.Color>
struct<image.ColorHSLA>
color_to_gray
color_to_gray(color) -> struct<image.ColorGRAY>
- color
struct<image.Color>
struct<image.ColorGRAY>
color_to_gray_average
color_to_gray_average(color) -> struct<image.ColorGRAY>
- color
struct<image.Color>
struct<image.ColorGRAY>
color_to_gray_weight
color_to_gray_weight(color, rWeight, gWeight, bWeight) -> struct<image.ColorGRAY>
- color
struct<image.Color> - rWeight
int - gWeight
int - bWeight
int
struct<image.ColorGRAY>
color_to_graya
color_to_graya(color) -> struct<image.ColorGRAYA>
Alpha is maintained.
- color
struct<image.Color>
struct<image.ColorGRAYA>
color_to_graya_average
color_to_graya_average(color) -> struct<image.ColorGRAYA>
Alpha is maintained.
- color
struct<image.Color>
struct<image.ColorGRAYA>
color_to_graya_weight
color_to_graya_weight(color, rWeight, gWeight, bWeight) -> struct<image.ColorGRAYA>
Alpha is maintained.
- color
struct<image.Color> - rWeight
int - gWeight
int - bWeight
int
struct<image.ColorGRAYA>
color_to_graya16
color_to_graya16(color) -> struct<image.ColorGRAYA16>
Alpha is maintained.
- color
struct<image.Color>
struct<image.ColorGRAYA16>
color_to_graya16_average
color_to_graya16_average(color) -> struct<image.ColorGRAYA16>
Alpha is maintained.
- color
struct<image.Color>
struct<image.ColorGRAYA16>
color_to_graya16_weight
color_to_graya16_weight(color, rWeight, gWeight, bWeight) -> struct<image.ColorGRAYA16>
Alpha is maintained.
- color
struct<image.Color> - rWeight
int - gWeight
int - bWeight
int
struct<image.ColorGRAYA16>
color_to_alpha
color_to_alpha(color) -> struct<image.ColorALPHA>
- color
struct<image.Color>
struct<image.ColorALPHA>
color_to_alpha16
color_to_alpha16(color) -> struct<image.ColorALPHA16>
- color
struct<image.Color>
struct<image.ColorALPHA16>
color_to_cmyk
color_to_cmyk(color) -> struct<image.ColorCMYK>
- color
struct<image.Color>
struct<image.ColorCMYK>
color_to_cmyka
color_to_cmyka(color) -> struct<image.ColorCMYKA>
- color
struct<image.Color>
struct<image.ColorCMYKA>
convert_color
convert_color(model, color) -> struct<image.ColorRGBA>
- model
int<image.ColorModel> - color
struct<image.Color>
struct<image.ColorRGBA>
draw
draw(id, src, x, y, width?, height?)
- id
int<collection.IMAGE> - src
int<collection.IMAGE>- To draw onto the base image. - x
int - y
int - width
int - height
int
draw_subimg
draw_subimg(id, src, x, y, pointx, pointy, width?, height?)
- id
int<collection.IMAGE> - src
int<collection.IMAGE>- To draw onto the base image. - x
int - y
int - pointx
int- X position on src. - pointy
int- Y position on src. - width
int - height
int
draw_overlay
draw_overlay(id, src, x, y, width?, height?)
Similar to image.draw but ignores pixels in src with an alpha of 0.
- id
int<collection.IMAGE> - src
int<collection.IMAGE>- To draw onto the base image. - x
int - y
int - width
int - height
int
draw_overlay_subimg
draw_overlay_subimg(id, src, x, y, pointx, pointy, width?, height?)
Similar to image.draw_subimg but ignores pixels in src with an alpha of 0.
- id
int<collection.IMAGE> - src
int<collection.IMAGE>- To draw onto the base image. - x
int - y
int - pointx
int- X position on src. - pointy
int- Y position on src. - width
int - height
int
draw_unsafe
draw_unsafe(id, src, x, y, width?, height?)
Note: Does not schedule a task onto `src`.
- id
int<collection.IMAGE> - src
int<collection.IMAGE>- To draw onto the base image. - x
int - y
int - width
int - height
int
draw_unsafe_subimg
draw_unsafe_subimg(id, src, x, y, width?, height?)
Note: Does not schedule a task onto `src`.
- id
int<collection.IMAGE> - src
int<collection.IMAGE>- To draw onto the base image. - x
int - y
int - pointx
int- X position on src. - pointy
int- Y position on src. - width
int - height
int
map
map(id, fn, invert?)
- id
int<collection.IMAGE> - fn
function(x int, y int, color struct<image.ColorRGBA>) -> struct<image.Color> - invert
bool- Reverses the looping order from columns to rows.
compare
compare(id1, id2) -> bool
@blocking
Compares two images pixel by pixel. Early returns if the image ids are the same, without scheduling any tasks.
- id1
int<collection.IMAGE> - id2
int<collection.IMAGE>
bool
ext_to_encoding
ext_to_encoding(ext) -> int<image.Encoding>
- ext
string
int<image.Encoding>
path_to_encoding
path_to_encoding(pth) -> int<image.Encoding>
First gets the ext from the path.
- pth
string
int<image.Encoding>
encoding_to_ext
encoding_to_ext(encoding) -> string
- encoding
int<image.Encoding>
string
extract_colors
extract_colors(img) -> []struct<image.ColorRGBA>
@blocking
- img
int<collection.IMAGE>
[]struct<image.ColorRGBA>
extract_colors_config
extract_colors_config(img, downSizeTo, smallBucket) -> []struct<image.ColorRGBA>
@blocking
- img
int<collection.IMAGE> - downSizeTo
float - smallBucket
float
[]struct<image.ColorRGBA>
png_data_chunk
png_data_chunk(key, data) -> struct<image.PNGDataChunk>
- key
string - data
string
struct<image.PNGDataChunk>
gif
gif(imgs, delay, loopCount, disposal?, backgroundIndex?) -> struct<image.GIF>
- imgs
[]int<collection.IMAGE> - delay
[]int - loopCount
int - disposal
[]int<image.GIFDisposal> - backgroundIndex
int
struct<image.GIF>
Constants
ColorModel
MODEL_RGBAMODEL_RGBA64MODEL_NRGBAMODEL_NRGBA64MODEL_ALPHAMODEL_ALPHA16MODEL_GRAYMODEL_GRAY16MODEL_CMYK
Encoding
ENCODING_PNGENCODING_JPEGENCODING_GIFENCODING_TIFFENCODING_BMPENCODING_ICOENCODING_CUR
ColorType
COLOR_TYPE_RGBACOLOR_TYPE_HSVACOLOR_TYPE_HSLACOLOR_TYPE_GRAYCOLOR_TYPE_GRAY16COLOR_TYPE_GRAYACOLOR_TYPE_GRAYA16COLOR_TYPE_ALPHACOLOR_TYPE_ALPHA16COLOR_TYPE_CMYKCOLOR_TYPE_CMYKACOLOR_TYPE_ZERO
GIFDisposal
GIFDISPOSAL_NONEGIFDISPOSAL_BACKGROUNDGIFDISPOSAL_PREVIOUS
WebPPreset
WEBPPRESET_DEFAULTWEBPPRESET_PICTUREWEBPPRESET_PHOTOWEBPPRESET_DRAWINGWEBPPRESET_ICONWEBPPRESET_TEXT
Structs
ImageNameOptions
- name
string - prefix
string - suffix
string
Point
- x
int - y
int
ColorRGBA
- type
string<image.ColorType> - red
int - green
int - blue
int - alpha
int
ColorHSVA
- type
string<image.ColorType> - hue
int - sat
int - value
int - alpha
int
ColorHSLA
- type
string<image.ColorType> - hue
int - light
int - value
int - alpha
int
ColorALPHA
- type
string<image.ColorType> - alpha
int
ColorALPHA16
- type
string<image.ColorType> - alpha
int
ColorGRAY
- type
string<image.ColorType> - gray
int
ColorGRAY16
- type
string<image.ColorType> - gray
int
ColorGRAYA
- type
string<image.ColorType> - gray
int - alpha
int
ColorGRAYA16
- type
string<image.ColorType> - gray
int - alpha
int
ColorCMYK
- type
string<image.ColorType> - cyan
int - magenta
int - yellow
int - key
int
ColorCMYKA
- type
string<image.ColorType> - cyan
int - magenta
int - yellow
int - key
int - alpha
int
ColorZERO
- type
string<image.ColorType>
PNGDataChunk
- key
string - data
string
GIF
- img
[]int<collection.IMAGE> - delay
[]int - disposal
[]int<image.GIFDisposal> - loop_count
int - background_index
int
Interfaces
Color
Color structs are automatically converted into the needed type. Do mind that some functions may return a different type than what was passed into it.
- type
string<image.ColorType>