class

Vips::MutableImage

Inherits Vips::Image / Vips::VipsObject / Vips::GObject / Reference / Object

Instance methods

[]=(index, value)

Use [] to set band elements on an image. For example

img = image.mutate { |x| x[1] = green }

will change band 1 ( the middle band)

Source
draw_circle(ink : Array(Float64), cx : Int32, cy : Int32, radius : Int32, **kwargs) : Nil

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

Source
draw_flood(ink : Array(Float64), x : Int32, y : Int32, **kwargs) : Nil

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

Source
draw_image(sub : Image, x : Int32, y : Int32, **kwargs) : Nil

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

Source
draw_line(ink : Array(Float64), x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32) : Nil

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

Source
draw_mask(ink : Array(Float64), mask : Image, x : Int32, y : Int32) : Nil

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

Source
draw_rect(ink : Array(Float64), left : Int32, top : Int32, width : Int32, height : Int32, **kwargs) : Nil

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

Source
draw_smudge(left : Int32, top : Int32, width : Int32, height : Int32) : Nil

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

Source
mutate

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.

Source
remove(name : String)

Remove a metadata item from an image. named metadata item is removed

Source
set(gtype : LibVips::GType, name : String, value)

Sets the type and value of an item of metadata. Any old item of the same name is removed. See GValue for types

Source
set(name : String, value)

Sets the value of an item of metadata. The metadata item must already exists

Source
to_s(io : IO)

Appends a short String representation of this object which includes its class name and its object address.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).to_s # => #<Person:0x10a199f20>
Source