Class: Griddle::Processor::ImageMagick
- Inherits:
-
Object
- Object
- Griddle::Processor::ImageMagick
- Defined in:
- lib/griddle/processor/image_magick.rb
Instance Method Summary collapse
- #crop ⇒ Object
- #crop? ⇒ Boolean
- #file_height ⇒ Object
- #file_width ⇒ Object
- #fit(geo = geometry) ⇒ Object
- #geometry ⇒ Object
- #height ⇒ Object
- #process_image(file, style) ⇒ Object
- #width ⇒ Object
Instance Method Details
#crop ⇒ Object
5 6 7 |
# File 'lib/griddle/processor/image_magick.rb', line 5 def crop `convert #{File.expand_path(@destination_file.path)} -crop #{geometry} -gravity Center #{@destination_file.path}` end |
#crop? ⇒ Boolean
9 10 11 |
# File 'lib/griddle/processor/image_magick.rb', line 9 def crop? @style.geometry =~ /#/ end |
#file_height ⇒ Object
25 26 27 |
# File 'lib/griddle/processor/image_magick.rb', line 25 def file_height file_dimensions.last end |
#file_width ⇒ Object
13 14 15 |
# File 'lib/griddle/processor/image_magick.rb', line 13 def file_width file_dimensions.first end |
#fit(geo = geometry) ⇒ Object
17 18 19 |
# File 'lib/griddle/processor/image_magick.rb', line 17 def fit(geo = geometry) `convert #{File.expand_path(@file.path)} -resize #{geo} #{@destination_file.path}` end |
#geometry ⇒ Object
21 22 23 |
# File 'lib/griddle/processor/image_magick.rb', line 21 def geometry @geometry ||= @style.geometry.gsub(/#/,'') end |
#height ⇒ Object
29 30 31 |
# File 'lib/griddle/processor/image_magick.rb', line 29 def height dimensions.last end |
#process_image(file, style) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/griddle/processor/image_magick.rb', line 33 def process_image file, style @style = style @file = file @destination_file = Tempfile.new @file.original_filename if crop? fit(resize_geometry_for_crop) crop else fit end @destination_file end |
#width ⇒ Object
46 47 48 |
# File 'lib/griddle/processor/image_magick.rb', line 46 def width dimensions.first end |