Vips::MutableImage
Inherits Vips::Image / Vips::VipsObject / Vips::GObject / Reference / Object
Instance methods
Use [] to set band elements on an image. For example
img = image.mutate { |x| x[1] = green }
will change band 1 ( the middle band)
Draw a circle on an image
# image.mutate { |x| x.draw_circle(ink, cx, cy, radius, {fill: Bool} }
Input Parameters
Required
ink : Array(Float64) - Color for pixels
cx : Int32 - Centre of draw_circle
cy : Int32 - Centre of draw_circle
radius : Int32 - Radius in pixels
Optionals
fill : Bool - Draw a solid object
Flood-fill an area
# image.mutate { |x| x.draw_flood(ink, x, y, {test: Image, equal: Bool} }
Input Parameters
Required
ink : Array(Float64) - Color for pixels
x : Int32 - DrawFlood start point
y : Int32 - DrawFlood start point
Optionals
test : Image - Test pixels in this image
equal : Bool - DrawFlood while equal to edge
Paint an image into another image
# image.mutate { |x| x.draw_image(sub, x, y, {mode: Enums::CombineMode} }
Input Parameters
Required
sub : Image - Sub-image to insert into main image
x : Int32 - Draw image here
y : Int32 - Draw image here
Optionals
mode : Enums::CombineMode - Combining mode
Draw a line on an image
# image.mutate { |x| x.draw_line(ink, x1, y1, x2, y2 }
Input Parameters
Required
ink : Array(Float64) - Color for pixels
x1 : Int32 - Start of draw_line
y1 : Int32 - Start of draw_line
x2 : Int32 - End of draw_line
y2 : Int32 - End of draw_line
Draw a mask on an image
# image.mutate { |x| x.draw_mask(ink, mask, x, y }
Input Parameters
Required
ink : Array(Float64) - Color for pixels
mask : Image - Mask of pixels to draw
x : Int32 - Draw mask here
y : Int32 - Draw mask here
Paint a rectangle on an image
# image.mutate { |x| x.draw_rect(ink, left, top, width, height, {fill: Bool} }
Input Parameters
Required
ink : Array(Float64) - Color for pixels
left : Int32 - Rect to fill
top : Int32 - Rect to fill
width : Int32 - Rect to fill
height : Int32 - Rect to fill
Optionals
fill : Bool - Draw a solid object
Blur a rectangle on an image
# image.mutate { |x| x.draw_smudge(left, top, width, height }
Input Parameters
Required
left : Int32 - Rect to fill
top : Int32 - Rect to fill
width : Int32 - Rect to fill
height : Int32 - Rect to fill
Mutate an image with a block. Inside the block, you can call methods which modify the image, such as setting or removing metadata, or modifying pixels.
For example:
image = image.mutate do |x|
(0..1).step 0.01 do |i|
x.draw_line([255.0], (x.width * i).to_i, 0, 0, (x.height * (1 - i)).to_i)
end
end
See MutableImage.
Sets the type and value of an item of metadata. Any old item of the
same name is removed. See GValue for types