Method: Paperclip::Geometry#transformation_to
- Defined in:
- lib/paperclip/geometry.rb
#transformation_to(dst, crop = false) ⇒ Object
Returns the scaling and cropping geometries (in string-based ImageMagick format) neccessary to transform this Geometry into the Geometry given. If crop is true, then it is assumed the destination Geometry will be the exact final resolution. In this case, the source Geometry is scaled so that an image containing the destination Geometry would be completely filled by the source image, and any overhanging image would be cropped. Useful for square thumbnail images. The cropping is weighted at the center of the Geometry.
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/paperclip/geometry.rb', line 94 def transformation_to(dst, crop = false) if crop ratio = Geometry.new(dst.width / width, dst.height / height) scale_geometry, scale = scaling(dst, ratio) crop_geometry = cropping(dst, ratio, scale) else scale_geometry = dst.to_s end [scale_geometry, crop_geometry] end |