Image.Draw (image v0.62.0)
View SourceFunctions to draw directly on a mutable image.
Note that while the functions in this module mutate an image, the mutations are performed on a copy of the image so no harm will come to other functions maintaining a reference to the original image.
Summary
Functions
Draw a circle on a mutable image.
Draw a circle on a mutable image returning the mutated image or raises an exception.
Flood-fill image with color, starting at position
top, left.
Flood-fill image with color, starting at position
top, left or raise an exception.
Draw one image over the top of a mutable image.
Draw one image over the top of a mutable image or raises an exception.
Validates acceptable circle dimensions
Validate a point location on an image
Draw a line on a mutable image.
Draw a line on a mutable image returning the mutated image or raising an exception.
Draw mask on the image.
Draw a point on a mutable image.
Draw a point on a mutable image returning the mutated image or raising an exception.
Draw a rectangle on a mutable image.
Draw a rectangle on a mutable image and returns the mutated image or raises an exception.
Smudge a section of image .
Types
@type box() :: %{ height: non_neg_integer(), width: non_neg_integer(), top: non_neg_integer(), left: non_neg_integer() }
Bounding box returned from Image.Draw.flood/4
Functions
@spec circle( Vix.Vips.Image.t() | Vix.Vips.MutableImage.t(), non_neg_integer(), non_neg_integer(), non_neg_integer(), Image.Options.Draw.circle() ) :: {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
Draw a circle on a mutable image.
Arguments
imageis anyt:Vimage.t/0or at:MutableImage.t/0upon which the rectangle will be drawn. Ifimageis at:MutableImage.t/0it will be mutated directly. Ifimageis at:Vimage.t/0it will be copied to at:MutableImage.t/0and then mutated.cxis the 0-based offset from the left edge of the image indicating where the center of the circle will be localed.cyis the 0-based offset from the top edge of the image indicating where the center of the circle will be localed.radiusis the radius of the drawn circle.optionsis a keyword list of options. The default iscolor: :black.
Options
:colordefines 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. Lastly, it can also be supplied as a hex string of the form#rrggbb. SeeImage.Color.color_map/0andImage.Color.rgb_color/1.:fillis a boolean indicating whether the rectangle is to be filled with:color. The default istrue.:stroke_widthindicates the width in pixels of the stroke that forms the rectangle. The default is1. Values greater than1will have a negative performance impact since the rectangle will be draw as 4 filled rectangles forming each of the four sides. Iffill: trueis set then this options is ignored.
Returns
{:ok, image}whereimageis the same type as that passed as an argument to the function.or
{:error, reason}
@spec circle!( Vix.Vips.Image.t() | Vix.Vips.MutableImage.t(), non_neg_integer(), non_neg_integer(), non_neg_integer(), Image.Options.Draw.circle() ) :: Vix.Vips.Image.t() | Vix.Vips.MutableImage.t() | no_return()
Draw a circle on a mutable image returning the mutated image or raises an exception.
Arguments
imageis anyt:Vimage.t/0or at:MutableImage.t/0upon which the rectangle will be drawn. Ifimageis at:MutableImage.t/0it will be mutated directly. Ifimageis at:Vimage.t/0it will be copied to at:MutableImage.t/0and then mutated.cxis the 0-based offset from the left edge of the image indicating where the center of the circle will be localed.cyis the 0-based offset from the top edge of the image indicating where the center of the circle will be localed.radiusis the radius of the drawn circle.optionsis a keyword list of options. The default iscolor: :black.
Options
:colordefines 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. Lastly, it can also be supplied as a hex string of the form#rrggbb. SeeImage.Color.color_map/0andImage.Color.rgb_color/1.:fillis a boolean indicating whether the rectangle is to be filled with:color. The default istrue.
Returns
imagewhereimageis the same type as that passed as an argument to the function orraises an exception.
@spec flood( Vix.Vips.Image.t() | Vix.Vips.MutableImage.t(), non_neg_integer(), non_neg_integer(), Image.Options.Draw.flood() ) :: {:ok, {Vix.Vips.Image.t(), box()}} | {: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
imageis anyt:Vimage.t/0or at:MutableImage.t/0upon which the rectangle will be drawn. Ifimageis at:MutableImage.t/0it will be mutated directly. Ifimageis at:Vimage.t/0it will be copied to at:MutableImage.t/0and then mutated.leftis the 0-based offset from the left edge of the image where the flood will be drawn.topis the 0-based offset from the top edge of the image where the flood will drawn.optionsis a keyword list of options. The default iscolor: :black.
Options
:colordefines 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. Lastly, it can also be supplied as a hex string of the form#rrggbb. SeeImage.Color.color_map/0andImage.Color.rgb_color/1.
Returns
{:ok, {image, height, width, top, left}whereimageis the same type as that passed as an argument to the function.heightandwidthrepresent the dimensions of the flood fill in pixels.topandleftare the 0-based offsets from the top and left location respectively of the flood area.or
{:error, reason}.
@spec flood!( Vix.Vips.Image.t() | Vix.Vips.MutableImage.t(), non_neg_integer(), non_neg_integer(), Image.Options.Draw.flood() ) :: Vix.Vips.Image.t() | no_return()
Flood-fill image with color, starting at position
top, left or raise an exception.
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
imageis anyt:Vimage.t/0or at:MutableImage.t/0upon which the rectangle will be drawn. Ifimageis at:MutableImage.t/0it will be mutated directly. Ifimageis at:Vimage.t/0it will be copied to at:MutableImage.t/0and then mutated.leftis the 0-based offset from the left edge of the image where the flood will be drawn.topis the 0-based offset from the top edge of the image where the flood will drawn.optionsis a keyword list of options. The default iscolor: :black.
Options
:colordefines 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. Lastly, it can also be supplied as a hex string of the form#rrggbb. SeeImage.Color.color_map/0andImage.Color.rgb_color/1.
Returns
imagewhereimageis the same type as that passed as an argument to the function orraises an exception.
@spec image( Vix.Vips.Image.t() | Vix.Vips.MutableImage.t(), Vix.Vips.Image.t(), non_neg_integer(), non_neg_integer(), Image.Options.Draw.image() ) :: {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
Draw one image over the top of a mutable image.
Arguments
imageis anyt:Vimage.t/0or at:MutableImage.t/0upon which the rectangle will be drawn. Ifimageis at:MutableImage.t/0it will be mutated directly. Ifimageis at:Vimage.t/0it will be copied to at:MutableImage.t/0and then mutated.sub_imageis anyt:Vimage.t/0that is drawn on top ofimage.leftis the 0-based offset from the left edge of the image where the sub-image will be drawn.topis the 0-based offset from the top edge of the image where the sub-image will be drawn.optionsis a keyword list of options. The default iscolor: :black.
Options
:colordefines 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. Lastly, it can also be supplied as a hex string of the form#rrggbb. SeeImage.Color.color_map/0andImage.Color.rgb_color/1.
Returns
{:ok, image}whereimageis the same type as that passed as an argument to the function.or
{:error, reason}
@spec image!( Vix.Vips.Image.t() | Vix.Vips.MutableImage.t(), Vix.Vips.Image.t(), non_neg_integer(), non_neg_integer(), Image.Options.Draw.image() ) :: Vix.Vips.Image.t() | Vix.Vips.MutableImage.t() | no_return()
Draw one image over the top of a mutable image or raises an exception.
Arguments
imageis anyt:Vimage.t/0or at:MutableImage.t/0upon which the rectangle will be drawn. Ifimageis at:MutableImage.t/0it will be mutated directly. Ifimageis at:Vimage.t/0it will be copied to at:MutableImage.t/0and then mutated.sub_imageis anyt:Vimage.t/0that is drawn on top ofimage.leftis the 0-based offset from the left edge of the image where the sub-image will be drawn.topis the 0-based offset from the top edge of the image where the sub-image will be drawn.optionsis a keyword list of options. The default iscolor: :black.
Options
:colordefines 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. Lastly, it can also be supplied as a hex string of the form#rrggbb. SeeImage.Color.color_map/0andImage.Color.rgb_color/1.
Returns
imagewhereimageis the same type as that passed as an argument to the function.raises an exception.
Validates acceptable circle dimensions
Validate a point location on an image
@spec line( Vix.Vips.Image.t() | Vix.Vips.MutableImage.t(), non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer(), Image.Options.Draw.line() ) :: {:ok, Vix.Vips.Image.t() | Vix.Vips.MutableImage.t()} | {:error, Image.error_message()}
Draw a line on a mutable image.
Arguments
imageis anyt:Vimage.t/0or at:MutableImage.t/0upon which the rectangle will be drawn. Ifimageis at:MutableImage.t/0it will be mutated directly. Ifimageis at:Vimage.t/0it will be copied to at:MutableImage.t/0and then mutated.x1,y1are the 0-based offsets from theleftandtopaccordingly indicating the point at the start of the line.x2,y2are the 0-based offsets from theleftandtopaccordingly indicating the point at the end of the line.optionsis a keyword list of options. The default iscolor: :black.
Options
:colordefines 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. Lastly, it can also be supplied as a hex string of the form#rrggbb. SeeImage.Color.color_map/0andImage.Color.rgb_color/1.
Returns
{:ok, image}whereimageis the same type as that passed as an argument to the function.or
{:error, reason}
@spec line!( Vix.Vips.Image.t() | Vix.Vips.MutableImage.t(), non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer(), Image.Options.Draw.line() ) :: Vix.Vips.Image.t() | Vix.Vips.MutableImage.t() | no_return()
Draw a line on a mutable image returning the mutated image or raising an exception.
Arguments
imageis anyt:Vimage.t/0or at:MutableImage.t/0upon which the rectangle will be drawn. Ifimageis at:MutableImage.t/0it will be mutated directly. Ifimageis at:Vimage.t/0it will be copied to at:MutableImage.t/0and then mutated.x1,y1are the 0-based offsets from theleftandtopaccordingly indicating the point at the start of the line.x2,y2are the 0-based offsets from theleftandtopaccordingly indicating the point at the end of the line.optionsis a keyword list of options. The default iscolor: :black.
Options
:colordefines 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. Lastly, it can also be supplied as a hex string of the form#rrggbb. SeeImage.Color.color_map/0andImage.Color.rgb_color/1.
Returns
imagewhereimageis the same type as that passed as an argument to the function orraises an exception.
@spec mask( Vix.Vips.Image.t() | 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.
@spec point( Vix.Vips.Image.t() | Vix.Vips.MutableImage.t(), non_neg_integer(), non_neg_integer(), Image.Options.Draw.point() ) :: {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
Draw a point on a mutable image.
Arguments
imageis anyt:Vimage.t/0or at:MutableImage.t/0upon which the rectangle will be drawn. Ifimageis at:MutableImage.t/0it will be mutated directly. Ifimageis at:Vimage.t/0it will be copied to at:MutableImage.t/0and then mutated.leftis the 0-based offset from the left edge of the image where the point will be drawn.topis the 0-based offset from the top edge of the image where the point will be drawn.optionsis a keyword list of options. The default iscolor: :black.
Options
:colordefines 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. Lastly, it can also be supplied as a hex string of the form#rrggbb. SeeImage.Color.color_map/0andImage.Color.rgb_color/1.
Returns
{:ok, image}whereimageis the same type as that passed as an argument to the function.or
{:error, reason}
@spec point!( Vix.Vips.Image.t() | Vix.Vips.MutableImage.t(), non_neg_integer(), non_neg_integer(), Image.Options.Draw.point() ) :: Vix.Vips.Image.t() | Vix.Vips.MutableImage.t() | no_return()
Draw a point on a mutable image returning the mutated image or raising an exception.
Arguments
imageis anyt:Vimage.t/0or at:MutableImage.t/0upon which the rectangle will be drawn. Ifimageis at:MutableImage.t/0it will be mutated directly. Ifimageis at:Vimage.t/0it will be copied to at:MutableImage.t/0and then mutated.leftis the 0-based offset from the left edge of the image where the point will be drawn.topis the 0-based offset from the top edge of the image where the point will be drawn.optionsis a keyword list of options. The default iscolor: :black. See the options forImage.Draw.point/4.
Returns
imagewhereimageis the same type as that passed as an argument to the function orraises an exception.
@spec rect( Vix.Vips.Image.t() | Vix.Vips.MutableImage.t(), non_neg_integer(), non_neg_integer(), pos_integer(), pos_integer(), Image.Options.Draw.rect() ) :: {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
Draw a rectangle on a mutable image.
Arguments
imageis anyt:Vimage.t/0or at:MutableImage.t/0upon which the rectangle will be drawn. Ifimageis at:MutableImage.t/0it will be mutated directly. Ifimageis at:Vimage.t/0it will be copied to at:MutableImage.t/0and then mutated.leftis the 0-based offset from the left edge of the image where the rectangle will be drawn.topis the 0-based offset from the top edge of the image where the rectangle will be drawn.widthis the width of the rectangleheightis the height of the rectangleoptionsis a keyword list of options. The default iscolor: :black.
Options
:colordefines 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. Lastly, it can also be supplied as a hex string of the form#rrggbb. SeeImage.Color.color_map/0andImage.Color.rgb_color/1.:fillis a boolean indicating whether the rectangle is to be filled with:color. The default istrue.:stroke_widthindicates the width in pixels of the stroke that forms the rectangle. The default is1. Values greater than1will have a negative performance impact since the rectangle will be draw as 4 filled rectangles forming each of the four sides. Iffill: trueis set then this options is ignored.
Returns
{:ok, image}whereimageis the same type as that passed as an argument to the function or{:error, reason}.
@spec rect!( Vix.Vips.Image.t() | Vix.Vips.MutableImage.t(), non_neg_integer(), non_neg_integer(), pos_integer(), pos_integer(), Image.Options.Draw.rect() ) :: Vix.Vips.Image.t() | Vix.Vips.MutableImage.t() | no_return()
Draw a rectangle on a mutable image and returns the mutated image or raises an exception.
Arguments
imageis anyt:Vimage.t/0or at:MutableImage.t/0upon which the rectangle will be drawn. Ifimageis at:MutableImage.t/0it will be mutated directly. Ifimageis at:Vimage.t/0it will be copied to at:MutableImage.t/0and then mutated.leftis the 0-based offset from the left edge of the image where the rectangle will be drawn.topis the 0-based offset from the top edge of the image where the rectangle will be drawn.widthis the width of the rectangleheightis the height of the rectangleoptionsis a keyword list of options. The default iscolor: :black.
Options
:colordefines 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. Lastly, it can also be supplied as a hex string of the form#rrggbb. SeeImage.Color.color_map/0andImage.Color.rgb_color/1.:fillis a boolean indicating whether the rectangle is to be filled with:color. The default istrue.:stroke_widthindicates the width in pixels of the stroke that forms the rectangle. The default is1. Values greater than1will have a negative performance impact since the rectangle will be draw as 4 filled rectangles forming each of the four sides. Iffill: trueis set then this options is ignored.
Returns
imagewhereimageis the same type as that passed as an argument to the function orraises an exception.
@spec smudge( Vix.Vips.Image.t() | Vix.Vips.MutableImage.t(), non_neg_integer(), non_neg_integer(), pos_integer(), pos_integer(), Image.Options.Draw.smudge() ) :: {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
Smudge a section of image .
Each pixel in the area left , top , width , height is replaced by the average of the surrounding 3x3 pixels.