GitXplorerGitXplorer
j

grunt-multiresize

public
5 stars
4 forks
4 issues

Commits

List of commits on branch master.
Unverified
c76c2a0b34ea3108ca46b9300d38150087d2feec

Merge pull request #5 from komachi/master

jjeduan committed 10 years ago
Unverified
2b9dddef2dd0747d003fc2a27b326753c9513611

Add background option.

kkomachi committed 10 years ago
Unverified
ed500aa6a5580317ab0ed548dfdfd31f2813e361

err returned undefined instead of null in tests

jjeduan committed 11 years ago
Unverified
c98be35514911392ad67bc3e166be593b8f60981

Updating dependencies

jjeduan committed 11 years ago
Unverified
b8e2e0745bc9939c8a14ddf0c72126fef01a4133

Merge pull request #3 from afternoon/master

jjeduan committed 11 years ago
Unverified
dcb30656810e32d4198a2b598be39daeb73bac92

Use resize+crop with gravity

aafternoon committed 11 years ago

README

The README file for this repository.

grunt-multiresize

Export multiple sizes from an image

Getting Started

This plugin requires GraphicsMagick and Grunt ~0.4.1

First download and install GraphicsMagick. In Mac OS X, you can simply use Homebrew and do:

brew install graphicsmagick

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-multiresize --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-multiresize');

The "multiresize" task

Overview

In your project's Gruntfile, add a section named multiresize to the data object passed into grunt.initConfig().

grunt.initConfig({
  multiresize: {
    target: {
      src: 'path/to/source',
      dest: ['path/to/dest1', '/path/to/dest2'],
      destSizes: ['72x72', '114x114']
    }
  },
})

Task

src

Type: String

The original file to be resized.

dest

Type: String or Array

The files to be written by this script.

destSizes

Type: Array

The image dimensions expected. The format can be witdhxheight or n%.

Options

options.background

Type: String

Background color, default transparent. The format described here.

options.quality

Type: String

Quality of output image, default 100.

Usage Examples

Outputting all icons

This project was originally created to resize our project icons to conform to CoronaSDK spec. This is our config file.

grunt.initConfig({
  multiresize: {
    iOS: {
      src: 'orig/Icon-512.png',
      dest: ['Icon.png', 'Icon@2x.png', 'Icon-72.png', 'Icon-72@2x.png'],
      destSizes: ['57x57', '114x114', '72x72', '144x144']
    },
    Android: {
      options: {
        background: '#ffffff'
      },
      src: 'orig/Icon-Android-512.png',
      dest: ['Icon-ldpi.png', 'Icon-mdpi.png', 'Icon-hdpi.png', 'Icon-xhdpi.png'],
      destSizes: ['36x36', '48x48', '72x72', '96x96']
    }
  },
})

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

v0.1.0: Initial release