Class: Imgry::Processor::ImageVoodoo

Inherits:
JavaAdapter show all
Defined in:
lib/imgry/processor/image_voodoo.rb

Instance Attribute Summary

Attributes inherited from Adapter

#format, #img, #img_blob

Instance Method Summary collapse

Methods inherited from JavaAdapter

#clean!, #crop_geometry, #detect_image_format!, #format, from_file, #height, #save, supported_formats, #to_blob, #width, with_bytes

Methods inherited from Adapter

#aspect_ratio, from_file, #initialize, #inspect, load_lib!, with_bytes

Constructor Details

This class inherits a constructor from Imgry::Processor::Adapter

Instance Method Details

#crop!(geometry) ⇒ Object



24
25
26
27
28
# File 'lib/imgry/processor/image_voodoo.rb', line 24

def crop!(geometry)
  width, height, offset_x, offset_y, flag = crop_geometry(geometry)

  @img = @img.with_crop(offset_x, offset_y, offset_x + width, offset_y + height)
end

#load_image!Object



5
6
7
8
9
10
11
12
13
# File 'lib/imgry/processor/image_voodoo.rb', line 5

def load_image!
  begin
    input_stream = ImageIO.create_image_input_stream(ByteArrayInputStream.new(@img_blob))
    detect_image_format!(input_stream)
    @img = ::ImageVoodoo.new(ImageIO.read(input_stream))
  rescue => ex
    raise InvalidImageError, ex.message
  end
end

#resize!(geometry) ⇒ Object



19
20
21
22
# File 'lib/imgry/processor/image_voodoo.rb', line 19

def resize!(geometry)
  return if geometry.nil?
  @img = @img.resize(*Geometry.scale(width, height, geometry))
end

#srcObject



15
16
17
# File 'lib/imgry/processor/image_voodoo.rb', line 15

def src
  @img.src
end