Class Paperclip::Geometry
In: lib/paperclip/geometry.rb
Parent: Object

Defines the geometry of an image.

Methods

aspect   from_file   horizontal?   inspect   larger   new   parse   smaller   square?   to_s   transformation_to   vertical?  

Attributes

height  [RW] 
modifier  [RW] 
width  [RW] 

Public Class methods

Uses ImageMagick to determing the dimensions of a file, passed in as either a File or path. NOTE: (race cond) Do not reassign the ‘file’ variable inside this method as it is likely to be a Tempfile object, which would be eligible for file deletion when no longer referenced.

Gives a Geometry representing the given height and width

Parses a "WxH" formatted string, where W is the width and H is the height.

Public Instance methods

The aspect ratio of the dimensions.

True if the dimensions represent a horizontal rectangle

Returns the larger of the two dimensions

Returns the smaller of the two dimensions

True if the dimensions represent a square

Returns the width and height in a format suitable to be passed to Geometry.parse

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.

True if the dimensions represent a vertical rectangle

[Validate]