JPEG and PNG compression processor for Paperclip using Tinify API.
Add to your Gemfile.
gem 'paperclip-tinify'
Configure your API key in config/initializers/paperclip.rb:
Paperclip::Tinify.tinify_key = 'YOUR_API_KEY'
By default, images will be compressed only in production environment. You can enable compression in other environments as follows:
Paperclip::Tinify.environments = [:development, :production]
Please visit Tinify to generate your API key.
This is the basic usage. This will compress both JPEG and PNG files with the default options.
class User < ActiveRecord::Base
has_attached_file :avatar,
styles: { medium: '300x300>', thumb: '100x100>' },
processors: [:tinify]
end
paperclip-tinify is released under the MIT License.