Module: AttachmentSaver::Processors::GdkPixbuf::Operations

Includes:
Image::Operations
Defined in:
lib/processors/gdk_pixbuf.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from 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 Attribute Details

#file_extensionObject

Returns the value of attribute file_extension.



90
91
92
# File 'lib/processors/gdk_pixbuf.rb', line 90

def file_extension
  @file_extension
end

#formatObject

Returns the value of attribute format.



90
91
92
# File 'lib/processors/gdk_pixbuf.rb', line 90

def format
  @format
end

Instance Method Details

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

crops to the center



100
101
102
103
104
105
106
# File 'lib/processors/gdk_pixbuf.rb', line 100

def crop_to(new_width, new_height, &block) # crops to the center
  image = new_subpixbuf((width - new_width)/2, (height - new_height)/2, new_width, new_height)
  image.extend Operations
  image.format = format
  image.file_extension = file_extension
  block.call(image)
end

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



92
93
94
95
96
97
98
# File 'lib/processors/gdk_pixbuf.rb', line 92

def resize_to(new_width, new_height, &block)
  image = scale(new_width, new_height)
  image.extend Operations
  image.format = format
  image.file_extension = file_extension
  block.call(image)
end