View Source Image.Draw (image v0.16.0)

Functions to draw directly on a mutable image.

Link to this section Summary

Functions

Draw a circle on a mutable image.

Flood-fill image with color, starting at position top, left .

Draw one image over the top of a mutable image.

Draw a line on a mutable image.

Draw mask on the image.

Draw a point on a mutable image.

Draw a rectangle on a mutable image.

Link to this section Functions

Link to this function

circle(image, cx, cy, radius, options \\ [])

View Source (since 0.7.0)

Draw a circle on a mutable image.

arguments

Arguments

  • image is any t:Vimage.t/0 or a t:MutableImage.t/0 upon which the circle will be drawn. The image will be mutated.

  • cx is the 0-based offset from the left edge of the image indicating where the center of the circle will be localed.

  • cy is the 0-based offset from the top edge of the image indicating where the center of the circle will be localed.

  • radius is the radius of the drawn circle.

  • options is a keyword list of options. The default is color: :black.

options

Options

  • :color defines the color of the point. This can be specified as a single integer which will be applied to all bands, or a list of integers representing the color for each band. The color can also be supplied as a CSS color name as a string or atom. For example: :misty_rose. See Image.Color.color_map/0 and Image.Color.rgb_color/1.

  • :fill is a boolean indicating whether the rectangle is to be filled with :color. The default is true.

returns

Returns

  • {:ok, image} where image is the same type as that passed as an argument to the function.

  • or {:error, reason}

Link to this function

flood(image, x, y, options \\ [])

View Source (since 0.7.0)
@spec flood(
  Vix.Vips.Image.t(),
  non_neg_integer(),
  non_neg_integer(),
  Image.Options.Draw.flood()
) ::
  {:ok,
   {Vix.Vips.Image.t(),
    height: integer(), width: integer(), top: integer(), left: integer()}}
  | {:error, Image.error_message()}
@spec flood(
  Vix.Vips.MutableImage.t(),
  non_neg_integer(),
  non_neg_integer(),
  Image.Options.Draw.flood()
) ::
  {:ok,
   {Vix.Vips.Image.t(),
    height: integer(), width: integer(), top: integer(), left: integer()}}
  | {:error, Image.error_message()}

Flood-fill image with color, starting at position top, left .

The filled area is bounded by pixels that are equal to the :colour. That is, it searches for pixels enclosed by an edge of :color.

If :equal is true, it instead searches for pixels which are equal to the start point and fills them with :color.

arguments

Arguments

  • image is any t:Vimage.t/0 or a t:MutableImage.t/0 upon which the the other image will be drawn. The image will be mutated.

  • left is the 0-based offset from the left edge of the image where the flood will be drawn.

  • top is the 0-based offset from the top edge of the image where the flood will drawn.

  • options is a keyword list of options. The default is color: :black.

options

Options

  • :color defines the color of the point. This can be specified as a single integer which will be applied to all bands, or a list of integers representing the color for each band. The color can also be supplied as a CSS color name as a string or atom. For example: :misty_rose. See Image.Color.color_map/0 and Image.Color.rgb_color/1.

returns

Returns

  • {:ok, image} where image is the same type as that passed as an argument to the function.

  • or {:error, reason}

Link to this function

image(image, sub_image, top, left, options \\ [])

View Source (since 0.7.0)

Draw one image over the top of a mutable image.

arguments

Arguments

  • image is any t:Vimage.t/0 or a t:MutableImage.t/0 upon which the the other image will be drawn. The image will be mutated.

  • sub_image is any t:Vimage.t/0 that is drawn on top of image.

  • left is the 0-based offset from the left edge of the image where the sub-image will be drawn.

  • top is the 0-based offset from the top edge of the image where the sub-image will be drawn.

  • options is a keyword list of options. The default is color: :black.

options

Options

  • :color defines the color of the point. This can be specified as a single integer which will be applied to all bands, or a list of integers representing the color for each band. The color can also be supplied as a CSS color name as a string or atom. For example: :misty_rose. See Image.Color.color_map/0 and Image.Color.rgb_color/1.

returns

Returns

  • {:ok, image} where image is the same type as that passed as an argument to the function.

  • or {:error, reason}

Link to this function

line(image, x1, y1, x2, y2, options \\ [])

View Source (since 0.7.0)

Draw a line on a mutable image.

arguments

Arguments

  • image is any t:Vimage.t/0 or a t:MutableImage.t/0 upon which the line will be drawn. The image will be mutated.

  • x1, y1 are the 0-based offsets from the left and top accordingly indicating the point at the start of the line.

  • x2, y2 are the 0-based offsets from the left and top accordingly indicating the point at the end of the line.

  • options is a keyword list of options. The default is color: :black.

options

Options

  • :color defines the color of the point. This can be specified as a single integer which will be applied to all bands, or a list of integers representing the color for each band. The color can also be supplied as a CSS color name as a string or atom. For example: :misty_rose. See Image.Color.color_map/0 and Image.Color.rgb_color/1.

returns

Returns

  • {:ok, image} where image is the same type as that passed as an argument to the function.

  • or {:error, reason}

Link to this function

mask(image, mask, x, y, options \\ [])

View Source (since 0.7.0)
@spec mask(
  Vix.Vips.Image.t(),
  Vix.Vips.Image.t(),
  non_neg_integer(),
  non_neg_integer(),
  Image.Options.Draw.mask()
) ::
  {:ok,
   {Vix.Vips.Image.t(),
    height: integer(), width: integer(), top: integer(), left: integer()}}
  | {:error, Image.error_message()}
@spec mask(
  Vix.Vips.MutableImage.t(),
  Vix.Vips.Image.t(),
  non_neg_integer(),
  non_neg_integer(),
  Image.Options.Draw.mask()
) ::
  {:ok,
   {Vix.Vips.Image.t(),
    height: integer(), width: integer(), top: integer(), left: integer()}}
  | {:error, Image.error_message()}

Draw mask on the image.

Mask is a monochrome 8-bit image with the values of 0 or 255 for transparent and any other value as a color to be blended into the base image.

Link to this function

maybe_add_alpha(image, color)

View Source
Link to this function

point(image, left, top, options \\ [])

View Source (since 0.7.0)

Draw a point on a mutable image.

arguments

Arguments

  • image is any t:Vimage.t/0 or a t:MutableImage.t/0 upon which the point will be drawn. The image will be mutated.

  • left is the 0-based offset from the left edge of the image where the point will be drawn.

  • top is the 0-based offset from the top edge of the image where the point will be drawn.

  • options is a keyword list of options. The default is color: :black.

options

Options

  • :color defines the color of the point. This can be specified as a single integer which will be applied to all bands, or a list of integers representing the color for each band. The color can also be supplied as a CSS color name as a string or atom. For example: :misty_rose. See Image.Color.color_map/0 and Image.Color.rgb_color/1.

returns

Returns

  • {:ok, image} where image is the same type as that passed as an argument to the function.

  • or {:error, reason}

Link to this function

rect(image, left, top, width, height, options \\ [])

View Source (since 0.7.0)

Draw a rectangle on a mutable image.

arguments

Arguments

  • image is any t:Vimage.t/0 or a t:MutableImage.t/0 upon which the rectangle will be drawn. The image will be mutated.

  • left is the 0-based offset from the left edge of the image where the rectangle will be drawn.

  • top is the 0-based offset from the top edge of the image where the rectangle will be drawn.

  • width is the width of the rectangle

  • height is the height of the rectangle

  • options is a keyword list of options. The default is color: :black.

options

Options

  • :color defines the color of the point. This can be specified as a single integer which will be applied to all bands, or a list of integers representing the color for each band. The color can also be supplied as a CSS color name as a string or atom. For example: :misty_rose. See Image.Color.color_map/0 and Image.Color.rgb_color/1.

  • :fill is a boolean indicating whether the rectangle is to be filled with :color. The default is true.

returns

Returns

  • {:ok, image} where image is the same type as that passed as an argument to the function.

  • or {:error, reason}

Link to this function

smudge(image, left, top, width, height, options \\ [])

View Source (since 0.7.0)

Smudge a section of image .

Each pixel in the area left , top , width , height is replaced by the average of the surrounding 3x3 pixels.