Filter

Library for applying lists of filters onto images.


Source: pkg/lua/lib/filter.go | Import: filter

Functions


draw

draw(id1, id2, filters, disableParallelization?)

Applies the filters to image1 with the output going into image2.

Arguments

  • id1 int<collection.IMAGE>
  • id2 int<collection.IMAGE>
  • filters []struct<filter.Filter>
  • disableParallelization bool
draw_at

draw_at(id1, id2, point, op, filters, disableParallelization?)

Applies the filters to image1 with the output going into image2.

Arguments

  • id1 int<collection.IMAGE>
  • id2 int<collection.IMAGE>
  • point struct<image.Point>
  • op int<filter.Operator>
  • filters []struct<filter.Filter>
  • disableParallelization bool
draw_at_xy

draw_at_xy(id1, id2, x, y, op, filters, disableParallelization?)

Applies the filters to image1 with the output going into image2.

Arguments

  • id1 int<collection.IMAGE>
  • id2 int<collection.IMAGE>
  • x int
  • y int
  • op int<filter.Operator>
  • filters []struct<filter.Filter>
  • disableParallelization bool
bounds

bounds(id, filters, disableParallelization?) -> int, int, int, int

@blocking

Gets the resulting bounds of the image after the filters are applied.

Arguments

  • id int<collection.IMAGE>
  • filters []struct<filter.Filter>
  • disableParallelization bool
Return Values

  • int - X position of the top left corner of the images bounds after the filters are applied.
  • int - Y position of the top left corner of the images bounds after the filters are applied.
  • int - X position of the bottom right corner of the images bounds after the filters are applied.
  • int - Y position of the bottom right corner of the images bounds after the filters are applied.
bounds_size

bounds_size(id, filters, disableParallelization?) -> int, int

@blocking

Gets the resulting size of the image after the filters are applied.

Arguments

  • id int<collection.IMAGE>
  • filters []struct<filter.Filter>
  • disableParallelization bool
Return Values

  • int - Width of the image after the filters are applied.
  • int - Height of the image after the filters are applied.
brightness

brightness(percent) -> struct<filter.FilterBrightness>

Arguments

  • percent float - Percent value between -100 and 100.
Return Values

  • struct<filter.FilterBrightness>
color_balance

color_balance(percentRed, percentGreen, percentBlue) -> struct<filter.FilterColorBalance>

Arguments

  • percentRed float - Percent values between -100 and 500.
  • percentGreen float - Percent values between -100 and 500.
  • percentBlue float - Percent values between -100 and 500.
Return Values

  • struct<filter.FilterColorBalance>
colorize

colorize(hue, saturation, percent) -> struct<filter.FilterColorize>

Arguments

  • hue float - Hue value between 0 and 360.
  • saturation float - Saturation value between 0 and 100.
  • percent float - Percent value between 0 and 100.
Return Values

  • struct<filter.FilterColorize>
colorspace_linear_to_srgb

colorspace_linear_to_srgb() -> struct<filter.FilterColorspaceLinearToSRGB>

Return Values

  • struct<filter.FilterColorspaceLinearToSRGB>
colorspace_srgb_to_linear

colorspace_srgb_to_linear() -> struct<filter.FilterColorspaceSRGBToLinear>

Return Values

  • struct<filter.FilterColorspaceSRGBToLinear>
contrast

contrast(percent) -> struct<filter.FilterContrast>

Arguments

  • percent float - Percent values between -100 and 100.
Return Values

  • struct<filter.FilterContrast>
convolution

convolution(kernel, normalize, alpha, abs, delta) -> struct<filter.FilterConvolution>

Arguments

  • kernel []float - Must have a length of an odd square, e.g. 3x3=9 or 5x5=25.
  • normalize bool
  • alpha bool
  • abs bool
  • delta float
Return Values

  • struct<filter.FilterConvolution>
crop

crop(min, max) -> struct<filter.FilterCrop>

Arguments

  • min struct<image.Point> - Top left corner of new image.
  • max struct<image.Point> - Bottom right corner of new image.
Return Values

  • struct<filter.FilterCrop>
crop_xy

crop_xy(xmin, ymin, xmax, ymax) -> struct<filter.FilterCrop>

Arguments

  • xmin int - X position of the top left corner.
  • ymin int - Y position of the top left corner.
  • xmax int - X position of the bottom right corner.
  • ymax int - Y position of the bottom right corner.
Return Values

  • struct<filter.FilterCrop>
crop_to_size

crop_to_size(width, height, anchor) -> struct<filter.FilterCropToSize>

Arguments

  • width int - Width of the new image.
  • height int - Height of the new image.
  • anchor int<filter.Anchor>
Return Values

  • struct<filter.FilterCropToSize>
flip_horizontal

flip_horizontal() -> struct<filter.FilterFlipHorizontal>

Return Values

  • struct<filter.FilterFlipHorizontal>
flip_vertical

flip_vertical() -> struct<filter.FilterFlipVertical>

Return Values

  • struct<filter.FilterFlipVertical>
gamma

gamma(gamma) -> struct<filter.FilterGamma>

Arguments

  • gamma float - Must be positive, a value of 1 maintains the image.
Return Values

  • struct<filter.FilterGamma>
gaussian_blur

gaussian_blur(sigma) -> struct<filter.FilterGaussianBlur>

Arguments

  • sigma float - Radius of blur is ~3*sigma.
Return Values

  • struct<filter.FilterGaussianBlur>
grayscale

grayscale() -> struct<filter.FilterGreyscale>

Return Values

  • struct<filter.FilterGreyscale>
invert

invert() -> struct<filter.FilterInvert>

Return Values

  • struct<filter.FilterInvert>
rotate

rotate(angle, bgcolor, interpolation) -> struct<filter.FilterRotate>

When doing rotations on multiples of 90 degrees, it is best to use the rotate filters for 90, 180, and 270.

Arguments

  • angle float - Angle value in degrees.
  • bgcolor struct<image.Color>
  • interpolation int<filter.Interpolation>
Return Values

  • struct<filter.FilterRotate>
rotate_90

rotate_90() -> struct<filter.FilterRotate90>

Return Values

  • struct<filter.FilterRotate90>
rotate_180

rotate_180() -> struct<filter.FilterRotate180>

Return Values

  • struct<filter.FilterRotate180>
rotate_270

rotate_270() -> struct<filter.FilterRotate270>

Return Values

  • struct<filter.FilterRotate270>
hue

hue(shift) -> struct<filter.FilterHue>

Arguments

  • shift float - Shift value between -180 and 180.
Return Values

  • struct<filter.FilterHue>
saturation

saturation(percent) -> struct<filter.FilterSaturation>

Arguments

  • percent float - Percent value between -100 and 500.
Return Values

  • struct<filter.FilterSaturation>
sepia

sepia(percent) -> struct<filter.FilterSepia>

Arguments

  • percent float - Percent value between 0 and 100.
Return Values

  • struct<filter.FilterSepia>
pixelate

pixelate(size) -> struct<filter.FilterPixelate>

Arguments

  • size int
Return Values

  • struct<filter.FilterPixelate>
threshold

threshold(percent) -> struct<filter.FilterThreshold>

Arguments

  • percent float - Percent value between 0 and 100.
Return Values

  • struct<filter.FilterThreshold>
transpose

transpose() -> struct<filter.FilterTranspose>

Return Values

  • struct<filter.FilterTranspose>
transverse

transverse() -> struct<filter.FilterTransverse>

Return Values

  • struct<filter.FilterTranverse>
sobel

sobel() -> struct<filter.FilterSobel>

Return Values

  • struct<filter.FilterSobel>
maximum

maximum(ksize, disk) -> struct<filter.FilterMaximum>

Arguments

  • ksize int - Must be odd int, e.g. 3, 5, 7.
  • disk bool - If the kernel used should be disk shaped instead of a square.
Return Values

  • struct<filter.FilterMaximum>
mean

mean(ksize, disk) -> struct<filter.FilterMean>

Arguments

  • ksize int - Must be odd int, e.g. 3, 5, 7.
  • disk bool - If the kernel used should be disk shaped instead of a square.
Return Values

  • struct<filter.FilterMean>
median

median(ksize, disk) -> struct<filter.FilterMedian>

Arguments

  • ksize int - Must be odd int, e.g. 3, 5, 7.
  • disk bool - If the kernel used should be disk shaped instead of a square.
Return Values

  • struct<filter.FilterMedian>
minimum

minimum(ksize, disk) -> struct<filter.FilterMinimum>

Arguments

  • ksize int - Must be odd int, e.g. 3, 5, 7.
  • disk bool - If the kernel used should be disk shaped instead of a square.
Return Values

  • struct<filter.FilterMinimum>
sigmoid

sigmoid(midpoint, factor) -> struct<filter.FilterSigmoid>

Adjusts the contrast of the image, but on a curve instead of linearly.

Arguments

  • midpoint float - Value between 0 and 1.
  • factor float
Return Values

  • struct<filter.FilterSigmoid>
unsharp_mask

unsharp_mask(sigma, amount, threshold) -> struct<filter.FilterUnsharpMask>

Arguments

  • sigma float - Radius is ~3*sigma.
  • amount float - Typically between 0.5 and 1.5.
  • threshold float - Minimum brightness change to sharpen, typically between 0 and 0.05.
Return Values

  • struct<filter.FilterUnsharpMask>
resize

resize(width, height, resampling) -> struct<filter.FilterResize>

Arguments

  • width int
  • height int
  • resampling int<filter.Resampling>
Return Values

  • struct<filter.FilterResize>
resize_to_fill

resize_to_fill(width, height, resampling, anchor) -> struct<filter.FilterResizeToFill>

Arguments

  • width int
  • height int
  • resampling int<filter.Resampling>
  • anchor int<filter.Anchor>
Return Values

  • struct<filter.FilterResizeToFill>
resize_to_fit

resize_to_fit(width, height, resampling) -> struct<filter.FilterResizeToFit>

Arguments

  • width int
  • height int
  • resampling int<filter.Resampling>
Return Values

  • struct<filter.FilterResizeToFit>
color_func

color_func(fn) -> struct<filter.FilterColorFunc>

Color values are floats between 0 and 1.

Arguments

  • fn function(r float, g float, b float, a float) -> float, float, float, float
Return Values

  • struct<filter.FilterColorFunc>
color_func_unsafe

color_func_unsafe(fn) -> struct<filter.FilterColorFuncUnsafe>

Color values are floats between 0 and 1. Note parallelization must be disabled when drawing for this to work. This has the benefit of not requiring new lua threads on each function call, but this means it is not thread safe.

Arguments

  • fn function(r float, g float, b float, a float) -> float, float, float, float
Return Values

  • struct<filter.FilterColorFuncUnsafe>

Constants


Anchor
  • ANCHOR_CENTER
  • ANCHOR_TOPLEFT
  • ANCHOR_TOP
  • ANCHOR_TOPRIGHT
  • ANCHOR_LEFT
  • ANCHOR_RIGHT
  • ANCHOR_BOTTOMLEFT
  • ANCHOR_BOTTOM
  • ANCHOR_BOTTOMRIGHT
Interpolation
  • INTERPOLATION_NEARESTNEIGHBOR
  • INTERPOLATION_LINEAR
  • INTERPOLATION_CUBIC
Operator
  • OPERATOR_COPY
  • OPERATOR_OVER
Resampling
  • RESAMPLING_BOX
  • RESAMPLING_CUBIC
  • RESAMPLING_LANCZOS
  • RESAMPLING_LINEAR
  • RESAMPLING_NEARESTNEIGHBOR
FilterType
  • FILTER_BRIGHTNESS
  • FILTER_COLOR_BALANCE
  • FILTER_COLORIZE
  • FILTER_COLORSPACE_LINEAR_TO_SRGB
  • FILTER_COLORSPACE_SRGB_TO_LINEAR
  • FILTER_CONTRAST
  • FILTER_CONVOLUTION
  • FILTER_CROP
  • FILTER_CROP_TO_SIZE
  • FILTER_FLIP_HORIZONTAL
  • FILTER_FLIP_VERTICAL
  • FILTER_GAMMA
  • FILTER_GAUSSIAN_BLUR
  • FILTER_GRAYSCALE
  • FILTER_INVERT
  • FILTER_ROTATE
  • FILTER_ROTATE90
  • FILTER_ROTATE180
  • FILTER_ROTATE270
  • FILTER_HUE
  • FILTER_SATURATION
  • FILTER_SEPIA
  • FILTER_THRESHOLD
  • FILTER_PIXELATE
  • FILTER_SOBEL
  • FILTER_TRANSPOSE
  • FILTER_TRANSVERSE
  • FILTER_MAXIMUM
  • FILTER_MEAN
  • FILTER_MEDIAN
  • FILTER_MINIMUM
  • FILTER_SIGMOID
  • FILTER_UNSHARP_MASK
  • FILTER_RESIZE
  • FILTER_RESIZE_TO_FILL
  • FILTER_RESIZE_TO_FIT
  • FILTER_COLOR_FUNC
  • FILTER_COLOR_FUNC_UNSAFE

Structs


FilterBrightness

Properties

  • type string<filter.FilterType>
  • percent float
FilterColorBalance

Properties

  • type string<filter.FilterType>
  • percentRed float
  • percentGreen float
  • percentBlue float
FilterColorize

Properties

  • type string<filter.FilterType>
  • hue float
  • saturation float
  • percent float
FilterColorspaceLinearToSRGB

Properties

  • type string<filter.FilterType>
FilterColorspaceSRGBToLinear

Properties

  • type string<filter.FilterType>
FilterContrast

Properties

  • type string<filter.FilterType>
  • percent float
FilterConvolution

Properties

  • type string<filter.FilterType>
  • kernel []float
  • normalize bool
  • alpha bool
  • abs bool
  • delta float
FilterCrop

Properties

  • type string<filter.FilterType>
  • xmin int
  • ymin int
  • xmax int
  • ymax int
FilterCropToSize

Properties

  • type string<filter.FilterType>
  • width int
  • height int
  • anchor int<filter.Anchor>
FilterFlipHorizontal

Properties

  • type string<filter.FilterType>
FilterFlipVertical

Properties

  • type string<filter.FilterType>
FilterGamma

Properties

  • type string<filter.FilterType>
  • gamma float
FilterGaussianBlur

Properties

  • type string<filter.FilterType>
  • sigma float
FilterGrayscale

Properties

  • type string<filter.FilterType>
FilterInvert

Properties

  • type string<filter.FilterType>
FilterRotate

Properties

  • type string<filter.FilterType>
  • angle float
  • bgcolor struct<image.Color>
  • interpolation int<filter.Interpolation>
FilterRotate90

Properties

  • type string<filter.FilterType>
FilterRotate180

Properties

  • type string<filter.FilterType>
FilterRotate270

Properties

  • type string<filter.FilterType>
FilterHue

Properties

  • type string<filter.FilterType>
  • shift float
FilterSaturation

Properties

  • type string<filter.FilterType>
  • percent float
FilterSepia

Properties

  • type string<filter.FilterType>
  • percent float
FilterThreshold

Properties

  • type string<filter.FilterType>
  • percent float
FilterPixelate

Properties

  • type string<filter.FilterType>
  • size int
FilterTranspose

Properties

  • type string<filter.FilterType>
FilterTransverse

Properties

  • type string<filter.FilterType>
FilterSobel

Properties

  • type string<filter.FilterType>
FilterMaximum

Properties

  • type string<filter.FilterType>
  • ksize int
  • disk bool
FilterMean

Properties

  • type string<filter.FilterType>
  • ksize int
  • disk bool
FilterMedian

Properties

  • type string<filter.FilterType>
  • ksize int
  • disk bool
FilterMinimum

Properties

  • type string<filter.FilterType>
  • ksize int
  • disk bool
FilterSigmoid

Properties

  • type string<filter.FilterType>
  • midpoint float
  • factor float
FilterUnsharpMask

Properties

  • type string<filter.FilterType>
  • sigma float
  • amount float
  • threshold float
FilterResize

Properties

  • type string<filter.FilterType>
  • width int
  • height int
  • resampling int<filter.Resampling>
FilterResizeToFill

Properties

  • type string<filter.FilterType>
  • width int
  • height int
  • resampling int<filter.Resampling>
  • anchor int<filter.Anchor>
FilterResizeToFit

Properties

  • type string<filter.FilterType>
  • width int
  • height int
  • resampling int<filter.Resampling>
FilterColorFunc

Properties

  • type string<filter.FilterType>
  • fn function(r float, g float, b float, a float) -> float, float, float, float
FilterColorFuncUnsafe

Properties

  • type string<filter.FilterType>
  • fn function(r float, g float, b float, a float) -> float, float, float, float

Interfaces


Filter

Properties

  • type string<filter.FilterType>