Guest User

Untitled

a guest
Apr 26th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. # Example usage of Jcropper
  2.  
  3. # == Schema Information
  4. # Table name: image_models
  5. #
  6. # id :integer(4) not null, primary key
  7. # image_file_name :string(255)
  8. # image_content_type :string(255)
  9. # image_file_size :integer(4)
  10. # image_updated_at :datetime
  11. # crop_x :integer(4) default(0)
  12. # crop_y :integer(4) default(0)
  13. # crop_h :integer(4) default(0)
  14. # crop_w :integer(4) default(0)
  15. #
  16.  
  17. class ImageModel < ActiveRecord::Base
  18. has_attached_file :image,
  19. :styles => {
  20. :resized => '120x41>',
  21. :cropped => '100%x100%'
  22. },
  23. :processors => [:jcropper],
  24. :convert_options => { :all => proc { |m| "-crop #{m.crop_w}x#{m.crop_h}+#{m.crop_x}+#{m.crop_y}" } }
  25.  
  26. def crop_settings
  27. [crop_x, crop_y, (crop_x+crop_w), (crop_y+crop_h)]
  28. end
  29. end
Add Comment
Please, Sign In to add comment