Code Monkey home page Code Monkey logo

img-lint's Introduction

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.

img-lint's People

Contributors

makaroni4 avatar

Stargazers

Jonas Calvi Meinerz avatar Tatiana S. avatar Andy Waite avatar Weston Ganger avatar Dmitry Koprov avatar Artem Tyurin avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.