38

I would like to crop images on upload using Paperclip to get square thumbs from the center of the original picture. I find out a method in documentation that seems to do exactly what I want:

transformation_to(dst, crop = false)

The problem is that I can't figure out where to use this method. It would be great to simply pass something as a parameter here:

  has_attached_file :picture, 
                    :styles => { :medium => "600x600>", :thumb => "something here" }
Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
collimarco
  • 34,231
  • 36
  • 108
  • 142

1 Answers1

70

You only need to use # instead of > as a parameter:

has_attached_file :picture, :styles => { :thumb => "200x200#" }
collimarco
  • 34,231
  • 36
  • 108
  • 142
  • 4
    The # is paperclip specific. Paperclip uses it as a marker to center and crop the image. You can look at https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip/thumbnail.rb for more. – Puhlze Oct 11 '13 at 15:43
  • 1
    Paperclip documentation about resizing and cropping options here: https://github.com/thoughtbot/paperclip/wiki/Thumbnail-Generation#resizing-options – lgx Sep 21 '15 at 15:37