Class: Miso::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/miso/image.rb,
lib/miso/factory.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_file, processor_class = nil) ⇒ Image

Returns a new instance of Image.



5
6
7
8
# File 'lib/miso/image.rb', line 5

def initialize(input_file, processor_class=nil)
  processor_class ||= Processor.processor_class
  @processor  = processor_class.new(input_file)
end

Instance Attribute Details

#processorObject (readonly)

Returns the value of attribute processor.



3
4
5
# File 'lib/miso/image.rb', line 3

def processor
  @processor
end

Class Method Details

.auto_orient(input_file, output_file, processor_class = nil) ⇒ Object



60
61
62
# File 'lib/miso/image.rb', line 60

def self.auto_orient(input_file, output_file, processor_class = nil)
  new(input_file, processor_class).auto_orient.write(output_file)
end

.crop(input_file, output_file, width, height, processor_class = nil) ⇒ Object

Class shortcut methods



52
53
54
# File 'lib/miso/image.rb', line 52

def self.crop(input_file, output_file, width, height, processor_class = nil)
  new(input_file, processor_class).crop(width, height).write(output_file)
end

.dimensions(input_file, processor_class = nil) ⇒ Object



64
65
66
# File 'lib/miso/image.rb', line 64

def self.dimensions(input_file, processor_class = nil)
  new(input_file, processor_class).dimensions
end

.factory(processor_class = Processor.processor_class) ⇒ Object



3
4
5
# File 'lib/miso/factory.rb', line 3

def self.factory(processor_class = Processor.processor_class)
  Factory.new(processor_class)
end

.fit(input_file, output_file, width, height, processor_class = nil) ⇒ Object



56
57
58
# File 'lib/miso/image.rb', line 56

def self.fit(input_file, output_file, width, height, processor_class = nil)
  new(input_file, processor_class).fit(width, height).write(output_file)
end

Instance Method Details

#auto_orientObject



22
23
24
25
# File 'lib/miso/image.rb', line 22

def auto_orient
  @processor.auto_orient
  return self
end

#crop(width, height) ⇒ Object

Basic methods



12
13
14
15
# File 'lib/miso/image.rb', line 12

def crop(width, height)
  @processor.crop(width, height)
  return self
end

#crop_fitting(width, height) ⇒ Object

Combined methods



46
47
48
# File 'lib/miso/image.rb', line 46

def crop_fitting(width, height)
  fit(width, height).crop(width, height)
end

#dimensionsObject



27
28
29
# File 'lib/miso/image.rb', line 27

def dimensions
  @processor.dimensions
end

#fit(width, height) ⇒ Object



17
18
19
20
# File 'lib/miso/image.rb', line 17

def fit(width, height)
  @processor.fit(width, height)
  return self
end

#heightObject



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

def height
  @processor.height
end

#widthObject



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

def width
  @processor.width
end

#write(output_file) ⇒ Object



39
40
41
42
# File 'lib/miso/image.rb', line 39

def write(output_file)
  @processor.write(output_file)
  self.class.new(output_file, @processor.class)
end