| Class | RMagickTransformationScript |
| In: |
lib/asset_compiler/rmagick_transformation_script.rb
|
| Parent: | Object |
Holds a reference to an instance of Magick::Image and manages operations on it. Used to provide a more consistent, higher-level api than is given by RMagick.
ImageTransformationScript automatically invokes Ruby’s garbage collector by calling GC.start upon instantiating a Magick::Image object. To bypass this, set the GC environment variable to ‘no’.
| GRAVITY_TYPES | = | { :none => Magick::ForgetGravity, :northwest => Magick::NorthWestGravity, :north => Magick::NorthGravity, :northeast => Magick::NorthEastGravity, :west => Magick::WestGravity, :center => Magick::CenterGravity, :east => Magick::EastGravity, :southwest => Magick::SouthWestGravity, :south => Magick::SouthGravity, :southeast => Magick::SouthEastGravity |
Initialize an ImageTransformationScript where img is either a path to an image or an instance of Magick::Image.
Resizes the image proportionally to fit the smaller dimension, then crops excess. Optionally, a gravity setting may be provided. From the RMagick docs:
Gravity provides a convenient way to locate objects irrespective of the size of the bounding region, in other words, you don't need to provide absolute coordinates in order to position an object.
The default gravity setting is :center. Available settings are:
Usage:
img.crop_to '64x64' # crops to center, 64x64 pixels img.crop_to '64x64', :north # crops to north - common for thumbnailing portraits
Darkens the image. Defaults to a blend factor of 25%.
img.darken # darkens the image 25%. img.darken 0.40 # darkens the image 40%.
Converts the image to greyscale.
img.greyscale # uses default overlay of #aa9955. img.greyscale '#aaaaaa' # uses specified overlay.
Applies an ICC profile to the image. Requires path which is a path to a file containing a valid ICC profile.
img.icc_profile 'srgb.icc'
Applies an ICM profile to the image. Requires path which is a path to a file containing a valid ICM profile.
img.icm_profile 'srgb.icm'
Lightens the image. Defaults to a blend factor of 25%.
img.lighten # lightens the image 25%. img.lighten 0.40 # lightens the image 40%.
Resizes the image to fit within the constraints specified by dimensions where dimensions is a String in the format of ‘WIDTHxLENGTH’.
img.size_to_fit '64x64'
Tints the image according to the following parameters:
Sharpen only the edges of the image. Parameters are: