{"id":13427875,"url":"https://github.com/jtescher/carrierwave-imageoptimizer","last_synced_at":"2025-04-12T19:50:56.511Z","repository":{"id":6517833,"uuid":"7758689","full_name":"jtescher/carrierwave-imageoptimizer","owner":"jtescher","description":"This gem allows you to simply optimize CarrierWave images via jpegoptim or optipng.","archived":false,"fork":false,"pushed_at":"2022-03-08T15:27:09.000Z","size":40,"stargazers_count":212,"open_issues_count":3,"forks_count":33,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-09T07:08:54.534Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/carrierwave-imageoptimizer","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jtescher.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-01-22T18:47:09.000Z","updated_at":"2024-02-15T15:41:08.000Z","dependencies_parsed_at":"2022-09-08T01:50:30.974Z","dependency_job_id":null,"html_url":"https://github.com/jtescher/carrierwave-imageoptimizer","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtescher%2Fcarrierwave-imageoptimizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtescher%2Fcarrierwave-imageoptimizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtescher%2Fcarrierwave-imageoptimizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtescher%2Fcarrierwave-imageoptimizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jtescher","download_url":"https://codeload.github.com/jtescher/carrierwave-imageoptimizer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625501,"owners_count":21135513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T01:00:41.786Z","updated_at":"2025-04-12T19:50:56.482Z","avatar_url":"https://github.com/jtescher.png","language":"Ruby","funding_links":[],"categories":["File Uploading","文件上传"],"sub_categories":["Omniauth"],"readme":"# CarrierWave ImageOptimizer\n\nThis gem allows you to simply optimize CarrierWave images via jpegoptim or optipng using the [image_optimizer](https://github.com/jtescher/image_optimizer) gem.\n\nTested against 2.2.x, 2.3.x, and ruby-head\n\n[![Build Status](https://secure.travis-ci.org/jtescher/carrierwave-imageoptimizer.svg)](http://travis-ci.org/jtescher/carrierwave-imageoptimizer)\n[![Code Climate](https://codeclimate.com/github/jtescher/carrierwave-imageoptimizer.svg)](https://codeclimate.com/github/jtescher/carrierwave-imageoptimizer)\n[![Coverage Status](https://coveralls.io/repos/jtescher/carrierwave-imageoptimizer/badge.svg)](https://coveralls.io/r/jtescher/carrierwave-imageoptimizer)\n[![Gem Version](https://badge.fury.io/rb/carrierwave-imageoptimizer.svg)](http://badge.fury.io/rb/carrierwave-imageoptimizer)\n\n## Installation\n\n##### This gem uses the following utilities for optimizing images:\n\n1. jpegoptim, which can be installed from the official [jpegoptim](https://github.com/tjko/jpegoptim) repository\n\n2. OptiPNG, which can be installed from [sourceforge.net](http://optipng.sourceforge.net/)\n\nOr install the utilities via homebrew:\n\n```bash\n$ brew install optipng jpegoptim\n```\n\nThen add this line to your application's Gemfile:\n\n    gem 'carrierwave-imageoptimizer'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install carrierwave-imageoptimizer\n\n### Installation on Heroku\nIf you are using Heroku for your production you must use [heroku buildpacks](https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app) in order to install `optipng` and `jpegoptim`. [jayzes](https://github.com/jayzes?tab=repositories) has some plug and play buildpacks to get you going in no time.\n\n__On an existing Heroku app and using the Heroku CLI__\n\n1. Add this gem to your gemfile.\n2. Modify your code following the instrunctions on the [usage](#usage) section.\n3. `heroku buildpacks:add --index 1 https://github.com/jayzes/heroku-buildpack-optipng`\n4. `heroku buildpacks:add --index 1 https://github.com/jayzes/heroku-buildpack-jpegoptim`\n5. `git push heroku` \n  * _It is important to do a push to heroku __after__ the buildpacks have been declared._\n\n## Usage\n\nTo add image optimization to your CarrierWave uploader, first include the module:\n\n```ruby\nclass MyUploader \u003c CarrierWave::Uploader::Base\n  include CarrierWave::ImageOptimizer\n  ...\nend\n```\n\nThen apply to all versions via:\n\n```ruby\nclass MyUploader \u003c CarrierWave::Uploader::Base\n  ...\n  process :optimize\nend\n```\n\nOr to a single image version via:\n\n```ruby\nclass MyUploader \u003c CarrierWave::Uploader::Base\n  ...\n  version :thumbnail do\n    process :optimize\n  end\nend\n```\n\n##### Lossy JPEG optimization\n\nPass an optional `quality` parameter to target a specific lossy JPG quality level (0-100), default is lossless\noptimization. PNGs will ignore the quality setting.\n\n```ruby\nclass MyUploader \u003c CarrierWave::Uploader::Base\n  ...\n  version :thumbnail do\n    process optimize: [{ quality: 50 }]\n  end\nend\n```\n\n##### Quiet Mode\n\nPass an optional `quiet` parameter to compress images without logging progress.\n\n```ruby\nclass MyUploader \u003c CarrierWave::Uploader::Base\n  ...\n  version :thumbnail do\n    process optimize: [{ quiet: true }]\n  end\nend\n```\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtescher%2Fcarrierwave-imageoptimizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjtescher%2Fcarrierwave-imageoptimizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtescher%2Fcarrierwave-imageoptimizer/lists"}