KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I would like to use jpegoptim or optipng to compress the image uploaded by users via Paperclip. I have a Paperclip model configured as: has_attached_file :image, :styles => {:thumb => '50x50>', :preview => '270x270>' }, :url => "/system/:class/:attachment/:id/:basename_:style.:extension", :path => ":rails_root/public/system/:class/:attachment/:id/:basename_:style.:extension" Question 1: Is it possible to compress the original image uploaded by user, then let Paperclip resize it , so there's only one compress process? and how to do it? Question 2: I am going to do it via the after_post_process callback, and I could get all the instances of three files from image.queued_for_write and I would like to trigger jpegoptim/optipng by the file extension, but when I use current_format = File.extname(file.path) , I get something like: .jpg20120508-7991-cqcpf2 . Is there away to get the extension string jpg ? or is it safe that I just check if the extension string is contained in that string?
Tags (comma-separated)
Save Edits
Cancel