SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class FileUploader < CommonUploader
  2.   def extension_whitelist
  3.     %w[pdf]
  4.   end
  5.  
  6.   def cover
  7.     manipulate! do |image|
  8.       image.format('png', 0) do |c|
  9.         c.fuzz        '3%'
  10.         c.trim
  11.         c.colorspace  'sRGB'
  12.       end
  13.       image
  14.     end
  15.   end
  16.  
  17.   version :preview do
  18.     process :cover
  19.     process convert: :png
  20.     process resize_to_fit: [200,200]
  21.  
  22.     def full_filename (for_file = model.source.file)
  23.       super.chomp(File.extname(super)) + '.png'
  24.     end
  25.   end
  26. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top