Git Product home page Git Product logo

retina-brunch's Introduction

retina-brunch

Automatically resizes images labeled at Retina sizes to lower resolutions. Plop an @2x image into an images folder, and get the normal version too. This must be used with the Brunch build tool.

Installing

retina-brunch is designed to be an npm package for use with the build tool Brunch. To install this as a dependency for your Brunch repository, run npm install --save retina-brunch, which will add a line to your package.json file.

Usage

By default, retina-brunch looks in the images directory in the public folder (the output folder) specified in your Brunch configuration. It then collects all the Retina files matching the regular expression /(@2[xX])\.(?:gif|jpeg|jpg|png)$/ and creates normal versions by halving the height and width and depositing the file in the same directory as the original.

Configuration Options

retina-brunch can be customized by adding retina to the plugins section of your config.coffee.

exports.config =
  plugins:
    retina:
      regexp: /(@2[xX])\.(?:gif|jpeg|jpg|png)$/
      path: 'images'
      minWidth: 0
      minHeight: 0
      assetsPath: 'public' # could be set to i.e. './app/assets'
  • RegExp regexp takes a Coffeescript/Javascript regular expression with exactly one group (if you specify more, they will be ignored; if you specify fewer, it will break) specifying the string that distinguishes a Retina file from a normal file. By convention, this is normally @2x or @2X. The name of the normal file will be determined by removing this group. The image resizing tool does not support image formats other than those already specified.
  • String path is the path to your images folder within the public folder specified in config.coffee, or any directory you want to monitor for files matching the Retina regular expresssion.
  • Integer minHeight and minWidth filter the files which are processed. In particular, a file's dimensions needs to be above both the minimum height and width for it to be processed.

Contributing

Watch & compile changes: coffee --watch --output lib/ src/

Todo

It would be interesting to add support for sizes greater than @2x. If one specified @3x for example, this would generate both a @2x and normal version.

retina-brunch's People

Contributors

garetht avatar

Watchers

Tom Boutell avatar 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.