You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is my progress so far with enhancing the README example for getting started with imagemin. I feel the current example isn't the best representation to getting started and found that it didn't work as depicted in the first example. Also most authors don't have just one image to optimize and if they do this new example still covers that scenario.
grunt-contrib-imagemin
Minify PNG and JPEG images
Getting Started
This plugin requires Grunt ~0.4.0
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-contrib-imagemin --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-contrib-imagemin');
Imagemin task
Run this task with the grunt imagemin command.
Task targets, files and options may be specified according to the grunt Configuring tasks guide.
The optimization level 0 enables a set of optimization operations that require minimal effort. There will be no changes to image attributes like bit depth or color type, and no recompression of existing IDAT datastreams. The optimization level 1 enables a single IDAT compression trial. The trial chosen is what. OptiPNG thinks it’s probably the most effective. The optimization levels 2 and higher enable multiple IDAT compression trials; the higher the level, the more trials.
grunt.initConfig({imagemin: {png: {options: {optimizationLevel: 7},files: [{expand: true,cwd: 'project-directory/img/',// cwd is 'current working directory'src: ['**/*.png'],dest: 'project-directory/img/compressed/',ext: '.png'}]},jpg: {options: {progressive: true},files: [{expand: true,// tell Grunt where to find our images and where to export them to.cwd: 'project-directory/img/',src: ['**/*.jpg'],dest: 'project-directory/img/compressed/',ext: '.jpg'}]}}});grunt.registerTask('default',['imagemin']);
Release History
2013-04-10 v0.1.4 Fix exception when running in verbose mode.
2013-04-05 v0.1.3 Fix OptiPNG not being able to overwrite file. Allow overwriting src when dest/src is the same. Limit to 10 concurrent optimizations.
2013-02-22 v0.1.2 Fix OptiPNG not working on some systems. Prevent OptiPNG from producing .bak files.
2013-02-15 v0.1.1 First official release for Grunt 0.4.0.
2013-01-30 v0.1.1rc8 Fix task not creating destination folders
2013-01-30 v0.1.1rc7 Updating to work with grunt v0.4.0rc7. Switching to this.files api.
PR welcome. But this is something that is common to all grunt tasks, and I find it too bad that the grunt docs isn't clear enough about this. Could you also open a ticket about it over at https://github.com/gruntjs/grunt-docs ?
This is my progress so far with enhancing the README example for getting started with imagemin. I feel the current example isn't the best representation to getting started and found that it didn't work as depicted in the first example. Also most authors don't have just one image to optimize and if they do this new example still covers that scenario.
grunt-contrib-imagemin![Build Status](https://camo.githubusercontent.com/4d4eea5abf5db60a6044828ea6ad621b50916550ec9eb83e4b475661ec10801f/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f6772756e746a732f6772756e742d636f6e747269622d696d6167656d696e2e706e673f6272616e63683d6d6173746572)
Getting Started
This plugin requires Grunt
~0.4.0
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:
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
Imagemin task
Run this task with the
grunt imagemin
command.Task targets, files and options may be specified according to the grunt Configuring tasks guide.
Minify images using OptiPNG and jpegtran.
Options
optimizationLevel (png only)
Type:
Number
Default:
0
Select optimization level between
0
and7
.Level and trials:
progressive (jpg only)
Type:
Boolean
Default:
false
Lossless conversion to progressive.
Example config (Original)
Example config (New proposed example)
Release History
Task submitted by Sindre Sorhus
This file was generated on Wed Apr 10 2013 20:04:49.
The text was updated successfully, but these errors were encountered: