Class: Gnawrnip::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/gnawrnip/image.rb

Instance Method Summary collapse

Constructor Details

#initialize(filepath) ⇒ Image

Returns a new instance of Image.



9
10
11
# File 'lib/gnawrnip/image.rb', line 9

def initialize(filepath)
  @filepath = filepath
end

Instance Method Details

#heightFixnum

Returns Height of image.

Returns:

  • (Fixnum)

    Height of image



31
32
33
# File 'lib/gnawrnip/image.rb', line 31

def height
  canvas.height
end

#resize(width, height) ⇒ Object



35
36
37
# File 'lib/gnawrnip/image.rb', line 35

def resize(width, height)
  canvas.resample_bilinear!(width, height)
end

#to_htmlObject



13
14
15
16
17
18
19
# File 'lib/gnawrnip/image.rb', line 13

def to_html
  width  = canvas.width
  height = canvas.height
  src    = canvas.to_data_url

  %Q(<img width="#{width}" height="#{height}" src="#{src}"/>)
end

#widthFixnum

Returns Width of image.

Returns:

  • (Fixnum)

    Width of image



24
25
26
# File 'lib/gnawrnip/image.rb', line 24

def width
  canvas.width
end