Skip to content

Instantly share code, notes, and snippets.

@dv
Created October 27, 2013 22:05
Show Gist options
  • Save dv/7188418 to your computer and use it in GitHub Desktop.
Save dv/7188418 to your computer and use it in GitHub Desktop.
# Important to tell Sprockets this is a binary type, else you'll get UTF-8 byte sequence errors
Rails.application.assets.register_mime_type 'image/png', '.png'
Rails.application.assets.register_postprocessor 'image/png', :png_compressor do |context, data|
IO.popen("pngquant -", "rb+") do |process|
process.write(data)
process.close_write
process.read
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment