Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Gem Version Build Status Maintainability Coverage Status Inline docs

img-lint logo

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.

Installation

gem install img-lint

or add it to your Gemfile and run bundle install:

gem 'img-lint', require: false

Usage

Run 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
-p/--path Path to a folder with images
-m/--max-size Max image size allowed in Kb
-f/--format Image formats, 'jpg,png,gif' by default
-h/--help Show help

Configuration

Run 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/**/**"

Configuration from .img-lint.yml will extend the default configuration.

Rake integration

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.

Contributing

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.

License

This project is released under the MIT License.

About

Lightweight gem that detects heavy images in your project.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages