diff --git a/README.md b/README.md index c1d6de6..c490405 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,8 @@ Generate a coffeescript for cropping: rails generate cropper user avatar this should give you a file in: - - app/assets/javascripts/users.js.coffee + + app/assets/javascripts/users.js.coffee ## Usage @@ -48,7 +48,7 @@ Open your model file and add the cropper: class User < ActiveRecord::Base mount_uploader :avatar, AvatarUploader crop_uploaded :avatar ## Add this - end + end Render a view after creating/updating a user, add a `crop` action in your `controller.` For example: @@ -69,9 +69,9 @@ Render a view after creating/updating a user, add a `crop` action in your `contr format.json { render json: @user.errors, status: :unprocessable_entity } end end - end + end -For `Rails 4.x`, whitelist the cropping attributes - `fieldname_crop_x`, `fieldname_crop_y`, `fieldname_crop_w`, `fieldname_crop_h`. +For `Rails 4.x`, whitelist the cropping attributes - `fieldname_crop_x`, `fieldname_crop_y`, `fieldname_crop_w`, `fieldname_crop_h`. For example: @@ -100,7 +100,7 @@ Call process on the version you would like to be cropped: version :thumb do process crop: :avatar ## Crops this version based on original image resize_to_limit(100,100) - end + end If there are no versions, and original file is to be cropped directly then call the process directly within `AvatarUploader`, @@ -109,51 +109,51 @@ If there are no versions, and original file is to be cropped directly then call ##NOTES 1. Current Documentation is for **CarrierWave-Crop v0.1.2** -2. Supports processors `rmagick` and `mini-magick`. - +2. Supports processors `rmagick` and `mini-magick`. + **To use `rmagick`, add it in your `Gemfile` as:** gem 'rmagick', :require => 'RMagick' ## Specify appropriate version, if needed - Run `bundle` + Run `bundle` Include it in your CarrierWave Uploader. For example: class AvatarUploader < CarrierWave::Uploader::Base - include CarrierWave::RMagick + include CarrierWave::RMagick ... - end + end + + **To use `mini_magick`, add it in your `Gemfile` as:** - **To use `mini_magick`, add it in your `Gemfile` as:** - gem 'mini_magick' ## Specify appropriate version, if needed - Run `bundle` + Run `bundle` Include it in your CarrierWave Uploader. For example: class AvatarUploader < CarrierWave::Uploader::Base - include CarrierWave::MiniMagick + include CarrierWave::MiniMagick ... - end + end 3. Supports cropping of ONE attachment per model. Can be directly applied on original attachment if no versions exists. process crop: :avatar - + 4. Supports cropping of MULTIPLE versions of one attachment per model. 5. In form helpers, by default *original image* is rendered. To render a specific version for cropping pass `version` option. For example: - <%= f.cropbox :avatar , version: :medium %> - <%= f.peviewbox :avatar , version: :medium %> ## Pass the same version as specified in cropbox - + <%= f.cropbox :avatar , version: :medium %> + <%= f.previewbox :avatar , version: :medium %> ## Pass the same version as specified in cropbox + 6. By default `previewbox` has `100x100` dimensions and `cropbox` defaults to the target geometry for the version. `width` and `height` can be specified for these form helpers. BUT If you override ONE of width/height you MUST override both, otherwise passed option would be ignored. <%= f.cropbox :avatar, width: 550, height: 600 %> <%= f.previewbox :avatar, width: 200, height: 200 %> - -7. By default, `process crop: :avatar` will create the cropped version based on original image. + +7. By default, `process crop: :avatar` will create the cropped version based on original image. To resize the image to a particular dimension before cropping, pass two more arguments `width` and `height`. ## If ONLY "thumb" version is to be cropped @@ -164,9 +164,9 @@ If there are no versions, and original file is to be cropped directly then call version :thumb do ## To crop this version based on `jumbo` version, pass width = 600 and height = 600 ## Specify both width and height values otherwise they would be ignored - process crop: [:avatar, 600, 600] + process crop: [:avatar, 600, 600] resize_to_limit(100,100) - end + end ### Credits and resources * [CarrierWave](https://github.com/carrierwaveuploader/carrierwave)