Module: AttachmentSaver::Processors::ImageScience::Operations

Includes:
AttachmentSaver::Processors::Image::Operations
Defined in:
lib/processors/image_science.rb

Instance Method Summary collapse

Methods included from AttachmentSaver::Processors::Image::Operations

#cover_and_crop, #expand_to_fit, #scale_by, #scale_dimensions_to_fit, #scale_to_cover, #scale_to_fit, #shrink_to_fit, #squish

Instance Method Details

#crop_to(new_width, new_height, &block) ⇒ Object

crops to the center



83
84
85
86
87
88
89
90
# File 'lib/processors/image_science.rb', line 83

def crop_to(new_width, new_height, &block) # crops to the center
  left = (width - new_width)/2
  right = (height - new_height)/2
  with_crop(left, right, left + new_width, right + new_height) do |image|
    image.extend Operations
    block.call(image) # as for resize, with_crop doesn't take a block itself
  end
end

#file_type_extensionObject



72
73
74
# File 'lib/processors/image_science.rb', line 72

def file_type_extension
  file_type.downcase
end

#resize_to(new_width, new_height, &block) ⇒ Object



76
77
78
79
80
81
# File 'lib/processors/image_science.rb', line 76

def resize_to(new_width, new_height, &block)
  resize(new_width, new_height) do |image|
    image.extend Operations
    block.call(image) # ImageScience itself doesn't accept a block argument (it yields only)
  end
end