img-lint will help to keep your webapp from serving heavy and not optimized images. It's a zero-dependencies Ruby gem that will scan specified folders for images with size above a certain threshold. It could be run manually or easily integrated into CI.
gem install img-lint
or add it to your
Gemfile and run
gem 'img-lint', require: false
img-lint in your console to lint images in the current folder or pass some arguments like so:
img-lint -p /path/to/project -f "jpg,png" -m 30
|Command Line Flag||Description|
||Path to a folder with images|
||Max image size allowed in Kb|
||Image formats, 'jpg,png,gif' by default|
img-lint install from the command line to generate
.img-lint.yml config file:
max_file_size: 150 # Kb image_formats: "jpg,png,gif" exclude: - "tmp/**/**" - "vendor/**/**"
.img-lint.yml will extend the default configuration.
To execute scss-lint via a Rake task, add the following to your Rakefile:
require "img_lint/rake_task" IMGLint::RakeTask.new
Make sure to specify your config when running img-lint with Rake or in CI mode.
That would be awesome to see you involved: Try out
img-lint, give feedback via email or simply open an issue. If you're opening a PR, try to add some specs, so we keep the project stable:
bundle exec rspec
By participating, you are expected to honor Code of Conduct.
This project is released under the MIT License.