gruntjs / grunt-contrib-imagemin Goto Github PK
View Code? Open in Web Editor NEWMinify PNG, JPG, GIF and SVG images.
Home Page: https://gruntjs.com
License: MIT License
Minify PNG, JPG, GIF and SVG images.
Home Page: https://gruntjs.com
License: MIT License
Hi, when I try to install I get the following error
$ npm install grunt-contrib-imagemin
npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
npm http GET https://registry.npmjs.org/grunt-contrib-imagemin
npm http 200 https://registry.npmjs.org/grunt-contrib-imagemin
npm http GET https://registry.npmjs.org/chalk
npm http GET https://registry.npmjs.org/optipng-bin
npm http GET https://registry.npmjs.org/filesize
npm http GET https://registry.npmjs.org/jpegtran-bin
npm http 304 https://registry.npmjs.org/chalk
npm http 304 https://registry.npmjs.org/filesize
npm http 200 https://registry.npmjs.org/optipng-bin
npm http 200 https://registry.npmjs.org/jpegtran-bin
npm http GET https://registry.npmjs.org/has-color
npm http GET https://registry.npmjs.org/ansi-styles
npm http GET https://registry.npmjs.org/which
npm http GET https://registry.npmjs.org/tar
npm http GET https://registry.npmjs.org/mkdirp
npm http GET https://registry.npmjs.org/request
npm http GET https://registry.npmjs.org/mocha
npm http 304 https://registry.npmjs.org/ansi-styles
npm http 304 https://registry.npmjs.org/request
npm http 304 https://registry.npmjs.org/mkdirp
npm http 304 https://registry.npmjs.org/has-color
npm http 304 https://registry.npmjs.org/tar
npm http 304 https://registry.npmjs.org/which
npm http 304 https://registry.npmjs.org/mocha
npm http GET https://registry.npmjs.org/inherits
npm http GET https://registry.npmjs.org/block-stream
npm http GET https://registry.npmjs.org/fstream
npm http GET https://registry.npmjs.org/qs
npm http GET https://registry.npmjs.org/json-stringify-safe
npm http GET https://registry.npmjs.org/forever-agent
npm http GET https://registry.npmjs.org/tunnel-agent
npm http GET https://registry.npmjs.org/http-signature
npm http GET https://registry.npmjs.org/hawk
npm http GET https://registry.npmjs.org/aws-sign
npm http GET https://registry.npmjs.org/oauth-sign
npm http GET https://registry.npmjs.org/cookie-jar
npm http GET https://registry.npmjs.org/node-uuid
npm http GET https://registry.npmjs.org/mime
npm http GET https://registry.npmjs.org/form-data
npm http GET https://registry.npmjs.org/commander/0.6.1
npm http GET https://registry.npmjs.org/growl
npm http GET https://registry.npmjs.org/jade/0.26.3
npm http GET https://registry.npmjs.org/debug
npm http GET https://registry.npmjs.org/diff/1.0.2
npm http GET https://registry.npmjs.org/glob/3.2.1
npm http 304 https://registry.npmjs.org/block-stream
npm http 304 https://registry.npmjs.org/fstream
npm http 304 https://registry.npmjs.org/inherits
npm http 304 https://registry.npmjs.org/qs
npm http 304 https://registry.npmjs.org/forever-agent
npm http 304 https://registry.npmjs.org/json-stringify-safe
npm http GET https://registry.npmjs.org/rimraf
npm http GET https://registry.npmjs.org/graceful-fs
npm http 304 https://registry.npmjs.org/aws-sign
npm http 304 https://registry.npmjs.org/growl
npm http 304 https://registry.npmjs.org/node-uuid
npm http 304 https://registry.npmjs.org/http-signature
npm http 304 https://registry.npmjs.org/cookie-jar
npm http 304 https://registry.npmjs.org/oauth-sign
npm http 304 https://registry.npmjs.org/diff/1.0.2
npm http 304 https://registry.npmjs.org/debug
npm http 304 https://registry.npmjs.org/hawk
npm http 304 https://registry.npmjs.org/jade/0.26.3
npm http 304 https://registry.npmjs.org/form-data
npm http 304 https://registry.npmjs.org/mime
npm http 304 https://registry.npmjs.org/commander/0.6.1
npm http 304 https://registry.npmjs.org/glob/3.2.1
npm http GET https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/minimatch
npm http 304 https://registry.npmjs.org/tunnel-agent
npm http 304 https://registry.npmjs.org/rimraf
npm http GET https://registry.npmjs.org/combined-stream
npm http GET https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/assert-plus/0.1.2
npm http GET https://registry.npmjs.org/asn1/0.1.11
npm http GET https://registry.npmjs.org/ctype/0.5.2
npm http GET https://registry.npmjs.org/mkdirp/0.3.0
npm http GET https://registry.npmjs.org/hoek
npm http GET https://registry.npmjs.org/boom
npm http GET https://registry.npmjs.org/cryptiles
npm http GET https://registry.npmjs.org/sntp
npm http 304 https://registry.npmjs.org/graceful-fs
npm http 304 https://registry.npmjs.org/graceful-fs
npm http 304 https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/sigmund
npm http 304 https://registry.npmjs.org/combined-stream
npm http 304 https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/delayed-stream/0.0.5
npm http 304 https://registry.npmjs.org/ctype/0.5.2
npm http 304 https://registry.npmjs.org/asn1/0.1.11
npm http 304 https://registry.npmjs.org/mkdirp/0.3.0
npm http 304 https://registry.npmjs.org/assert-plus/0.1.2
npm http 304 https://registry.npmjs.org/hoek
npm http 304 https://registry.npmjs.org/boom
npm http 304 https://registry.npmjs.org/cryptiles
npm http 304 https://registry.npmjs.org/lru-cache
npm http 304 https://registry.npmjs.org/sigmund
npm http 304 https://registry.npmjs.org/sntp
npm http 304 https://registry.npmjs.org/delayed-stream/0.0.5
> [email protected] postinstall /Users/seb/dev/FDJ/git-www/sites/mobi/www/euml/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin
> node pre-build.js
> [email protected] postinstall /Users/seb/dev/FDJ/git-www/sites/mobi/www/euml/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin
> node pre-build.js
stream.js:94
throw er; // Unhandled stream error in pipe.
^
Error: connect Unknown system errno 64
at errnoException (net.js:901:11)
at connect (net.js:764:19)
at net.js:842:9
at asyncCallback (dns.js:68:16)
at Object.onanswer [as oncomplete] (dns.js:121:9)
stream.js:94
throw er; // Unhandled stream error in pipe.
^
Error: connect Unknown system errno 64
at errnoException (net.js:901:11)
at connect (net.js:764:19)
at net.js:842:9
at asyncCallback (dns.js:68:16)
at Object.onanswer [as oncomplete] (dns.js:121:9)
npm ERR! weird error 8
npm ERR! not ok code 0
https://github.com/pornel/improved-pngquant#readme
pngquant contributes huge filesize savings (usually 50-75%) for transparent pngs intended for the web at basically no cost; it is a mandatory part of my deployment process and it would be an awesome feature to work into this plugin!
> [email protected] postinstall /Users/kud/Sites/_kud/happy-plan/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin
> node pre-build.js
․ OptiPNG should return path to OptiPNG binary: 18ms
OptiPNG should proxy OptiPNG:
․ OptiPNG should proxy OptiPNG: 123ms
․ OptiPNG should minify a .png: 110ms
3 tests complete (266 ms)
pre-build test passed successfully, skipping build
1) jpegtran should return path to jpegtran binary
2) jpegtran should successfully proxy jpegtran
3) jpegtran should minify a .jpg
4) jpegtran "after all" hook
✖ 4 of 3 tests failed:
1) jpegtran should return path to jpegtran binary:
AssertionError: false == true
at /Users/kud/Sites/_kud/happy-plan/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/test/test-jpegtran-path.js:18:4
at ChildProcess.exithandler (child_process.js:636:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:730:16)
at Socket.<anonymous> (child_process.js:943:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:451:12)
2) jpegtran should successfully proxy jpegtran:
AssertionError: false == true
at /Users/kud/Sites/_kud/happy-plan/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/test/test-jpegtran-path.js:27:4
at ChildProcess.exithandler (child_process.js:630:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:730:16)
at Socket.<anonymous> (child_process.js:943:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:451:12)
3) jpegtran should minify a .jpg:
Error: ENOENT, no such file or directory 'test/minified.jpg'
at Object.fs.statSync (fs.js:684:18)
at /Users/kud/Sites/_kud/happy-plan/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/test/test-jpegtran-path.js:42:20
at ChildProcess.exithandler (child_process.js:630:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:730:16)
at Process.ChildProcess._handle.onexit (child_process.js:797:5)
4) jpegtran "after all" hook:
Error: ENOENT, no such file or directory 'test/minified.jpg'
at Object.fs.unlinkSync (fs.js:760:18)
at Context.<anonymous> (/Users/kud/Sites/_kud/happy-plan/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/test/test-jpegtran-path.js:11:6)
at Hook.Runnable.run (/Users/kud/Sites/_kud/happy-plan/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/node_modules/mocha/lib/runnable.js:213:32)
at next (/Users/kud/Sites/_kud/happy-plan/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/node_modules/mocha/lib/runner.js:243:10)
at Object._onImmediate (/Users/kud/Sites/_kud/happy-plan/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/node_modules/mocha/lib/runner.js:254:5)
at processImmediate [as _immediateCallback] (timers.js:317:15)
Getting this error when trying use imagemin on an entire folder.
Running "imagemin:build" (imagemin) task
Error: /Users/.../node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/vendor/osx/jpegtran: can't open distribute/public/img/ for writing
✔ source/public/img/test.jpg (saved 1.07MB)
Task looks like this:
grunt.config('imagemin', {
build: {
src : 'source/public/img/*',
dest : 'distribute/public/img/'
}
});
Using these versions:
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-imagemin": "~0.1.4",
"grunt-contrib-requirejs": "~0.4.0",
"grunt-contrib-jshint": "~0.4.3",
"grunt-contrib-concat": "~0.2.0",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-copy": "~0.4.1",
"lodash": "~1.1.1"
}
Lets say I have 50 images in a directory, jpg and png, would be great if you can provide an example of configuration to do that. Thank you
hi, I am using imagemin in an angularjs app and notices a problem, I am not sure how to solve.
angular apps use /views/ directory to load their templates. conceptually it's something like this:
<html>
...
<img src="test.jpg">
<view_container>...here a template from /views/template.html will be loaded </view_container>
...
</html>
where /views/template.html is:
<img src="test.jpg">
and the dir structure is:
index.html
test.jpg
views
template.html
now, imagemin minifies the image and replaces its url in the index.html file correctly, but fails to do it for template.html as it is in a subdirectory. so it does not detect the image to be the same (however, when I change it's url to ../test.jpg it updates its url).
the problem is, that the template is loaded as a part of index.html and "../test.jpg" is no longer valid.
is there any workaround for this kind of setup?
I wish imagemin detected "test.jpg" to be the same image even though template.html is in a subdirectory.
When I run the imagemin task again, I got the following status report:
* Status report
1 file(s) have been processed.
1 error(s) have been encountered.
✔ static-te/img/te/foot_img/0213.png (saved 6.63Kb)
Error: * Processing: static-te/img/te/foot_img/0212.png
112x40 pixels, 8 bits/pixel, 64 colors in palette
Stripping metadata...
The output file exists. Rerun OptiPNG with -backup enabled
Error: Can't overwrite the output file
I saw the Issue #2 closed, but it seems cause another issue, am I missed something?
My OptiPNG version 0.7.4, Using libpng version 1.4.12 and zlib version 1.2.7
I would like to have a way for imagemin to behave synchronously, such as the other *min tasks. I want to parse the output of my build command later, and this makes the task more complicated.
Here's my Gruntfile and here's an example of how the output goes:
$ grunt
Running "clean:0" (clean) task
Cleaning "dist"...OK
Running "prepare-dist" task
Folder created
Folder created
Running "build" task
Running "less:prod" (less) task
File app/css/styles.css created.
Running "htmlmin:dist" (htmlmin) task
File dist/index.html created.
Uncompressed size: 1091 bytes.
Compressed size: 263 bytes gzipped (1026 bytes minified).
Running "imagemin:dist" (imagemin) task
Running "cssmin:dist" (cssmin) task
File dist/css/styles.css created.
Original: 40229 bytes.
Minified: 38327 bytes.
Running "uglify:dist" (uglify) task
File "dist/application.js" created.
Running "jasmine:test" (jasmine) task
Testing jasmine specs via phantom
created: app/templates.js
created: app/index.js
✔ app/css/jquery-ui/cupertino/images/ui-bg_highlight-soft_25_ffef8f_1x100.png (saved 1.17Kb)
✔ app/css/jquery-ui/cupertino/images/ui-bg_highlight-soft_100_deedf7_1x100.png (saved 1.43Kb)
✔ app/css/jquery-ui/cupertino/images/ui-bg_highlight-hard_70_000000_1x100.png (saved 1.04Kb)
✔ app/css/jquery-ui/cupertino/images/ui-bg_highlight-hard_100_f2f5f7_1x100.png (saved 1.20Kb)
✔ app/css/jquery-ui/cupertino/images/ui-bg_glass_80_d7ebf9_1x400.png (saved 1.16Kb)
✔ app/css/jquery-ui/cupertino/images/ui-bg_glass_50_3baae3_1x400.png (saved 1.14Kb)
✔ app/css/jquery-ui/cupertino/images/ui-bg_glass_100_e4f1fb_1x400.png (saved 1.22Kb)
✔ app/css/jquery-ui/cupertino/images/ui-bg_flat_15_cd0a0a_40x100.png (saved 119.00B)
✔ app/css/jquery-ui/cupertino/images/ui-bg_diagonals-thick_90_eeeeee_40x40.png (saved 1.10Kb)
✔ app/imgs/apple-touch-icon.png (already optimized)
✔ app/imgs/apple-touch-icon-precomposed.png (already optimized)
✔ app/imgs/apple-touch-icon-72x72-precomposed.png (already optimized)
✔ app/imgs/apple-touch-icon-57x57-precomposed.png (already optimized)
✔ app/imgs/apple-touch-icon-114x114-precomposed.png (already optimized)
Done, without errors
$
I'm using grunt-contrib-imagemin plugin to optimise some images in a directory.
The idea is that imagemin should compress the existing images and NOT create duplicate ones with different names.
For some reason any images which have a period will be duplicated with a different name (name before first period), for example:
The code that I am using within gruntConfig is:
imagemin: {
dynamic_mappings: {
files: [
{
expand: true,
cwd: 'assets/graphics/',
src: ['**/*.png'],
dest: 'assets/graphics/',
ext: '.png'
}
]
}
}
What can I do to overcome this issue?
npm ERR! [email protected] postinstall: node pre-build.js
npm ERR! sh "-c" "node pre-build.js"
failed with 8
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is most likely a problem with the jpegtran-bin package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node pre-build.js
Seemingly random PNGs are cut off on output.
Source image: https://dl.dropboxusercontent.com/u/115284/pngsample/bubble_01.png
Output image: https://dl.dropboxusercontent.com/u/115284/pngsample/bubble_01_output.png
The image is a PNG-24 image output from Photoshop's "Save for web" dialogue. It features heavy transparency.
Settings:
imagemin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.{png,jpg,jpeg}',
dest: '<%= yeoman.dist %>/images'
}]
} // dist
},
When running grunt imagemin:dist
, regardless of changing settings, this file will always be cut off (and half a dozen more like it).
Update 1: If I start out with a png that has been saved with "interlaced" as an option (Photoshop's "save for web" dialogue), this is the new output (source still looks fine, of course):
Output with interlacing: https://dl.dropboxusercontent.com/u/115284/pngsample/bubble_01_output_interlaced.png
Update 2: Removing transparency from the source image outputs as expected.
It doesn't seem like Imagemin is moving gifs over to the 'dest' directory. My task is as follows:
imagemin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/img',
src: '{,*/}*.{png,jpg,jpeg,gif,webp}',
dest: '<%= yeoman.dist %>/img'
}]
}
}
38287 error Error: EPERM, open '/media/sf_D_DRIVE/Sites/_kud/kud.test/node_modules/happyplan/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js'
38287 error { [Error: EPERM, open '/media/sf_D_DRIVE/Sites/_kud/kud.test/node_modules/happyplan/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js']
38287 error errno: 50,
38287 error code: 'EPERM',
38287 error path: '/media/sf_D_DRIVE/Sites/_kud/kud.test/node_modules/happyplan/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js' }
38288 error Please try running this command again as root/Administrator.
38289 error System Linux 3.2.0-35-generic
38290 error command "node" "/usr/bin/npm" "install" "happyplan" "--save-dev"
38291 error cwd /media/sf_D_DRIVE/Sites/_kud/kud.test
38292 error node -v v0.10.5
38293 error npm -v 1.3.1
38294 error path /media/sf_D_DRIVE/Sites/_kud/kud.test/node_modules/happyplan/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js
38295 error code EPERM
38296 error errno 50
38297 error stack Error: EPERM, open '/media/sf_D_DRIVE/Sites/_kud/kud.test/node_modules/happyplan/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js'
38298 verbose exit [ 50, true ]
Do you know why I get this error? I'm already root.
Right now if my grunt looks like this:
imagemin: {
dist: {
files: {
'html/img/compressed/cart.png': 'html/img/cart.png',
}
}
}
.. and if I run the task multiple times, a file with name cart.png.bak
is created in the compressed
directory. Please consider adding an option to turn this off.
(Or is this an option that can be passed to OptiPNG? In that case the documentation should mention that).
Here's the output when running the task in verbose mode:
yadayadayda Options: optimizationLevel=3 Warning: Cannot read property 'stdout' of undefined Use --force to continue.
It seems that imagemin.js (v0.1.2) is lacking a test or maybe something else but the following kind of solves the issue:
if (cp && grunt.option('verbose')) {
cp.stdout.pipe(process.stdout);
cp.stderr.pipe(process.stderr);
}
This is currently my favourite grunt task for optimizing images in our build process. I would love to see gifsicle support to optimize gifs: http://www.lcdf.org/gifsicle/
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.
Minify PNG and JPEG images
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');
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.
Type: Number
Default: 0
Select optimization level between 0
and 7
.
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.
Level and trials:
Type: Boolean
Default: false
Lossless conversion to progressive.
grunt.initConfig({
imagemin: { // Task
dist: { // Target
options: { // Target options
optimizationLevel: 3
},
files: { // Dictionary of files
'dist/img.png': 'src/img.png', // 'destination': 'source'
'dist/img.jpg': 'src/img.jpg'
}
},
dev: { // Another target
options: { // Target options
optimizationLevel: 0
},
files: {
'dev/img.png': 'src/img.png',
'dev/img.jpg': 'src/img.jpg'
}
}
}
});
grunt.registerTask('default', ['imagemin']);
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']);
Task submitted by Sindre Sorhus
This file was generated on Wed Apr 10 2013 20:04:49.
any chance we can get this working again ?
ty
I am using compass to generate my sprites. After the compass task is run, I want to use grunt-contrib-imagemin
to optimize those generated sprites.
This is my config:
imagemin: {
options: {
optimizationLevel: 7
},
build: {
files: {
"../images/**/*.png": "../images/**/*.png" // 'destination': 'source'
"..images/**/*.jpg": "../images/**/*jpg"
}
}
}
For PNG files, I get the following error from optipng:
The output file exists. Rerun OptiPNG with -backup enabled
Error: Can't overwrite the output file
For jpegs, jpegtran just fails silently and the file does not seem to be overwritten.
Could a condition be added so that when the source and destination is the same, the optipng command is run with --backup
and the jpegtran is run with the appropriate flag?
Using Grunt 0.4.0, grunt-contrib-imagemin 0.1.1, node 0.8.20 on OS X and this task
imagemin: {
deploy: {
options: {
optimizationLevel: 0,
progressive: false
},
files: {
'dist/img/': 'img/*'
}
}
}
fails if there are no image files present in img
. Not only does the task fail without any warning, also the rest of the build script is not executed (if imagemin
is not the final task).
When trying to put some images in a folder outside of the working directory (in a temp folder), I get an error when the task tries to delete an image (since deleting files outside of the working directory requires passing the force
option). Should this task pass force
when calling grunt.file.delete
for files that it created?
Hi,
I'm trying to optimize the image using this config:
imagemin: {
dynamic: {
files: [{
expand: true,
cwd: 'assets/images/',
src: ['**/Atlas*.{png,jpg}'],
dest: 'assets/images/'
}]
}
},
But the system (Mac OS X 10.8.4) gives me an Assertion Failed. Here is the error:
Assertion failed: (!uv__io_active(&stream->io_watcher, UV__POLLOUT) || !ngx_queue_empty(&stream->write_completed_queue) || !ngx_queue_empty(&stream->write_queue) || stream->shutdown_req != NULL || stream->connect_req != NULL), function uv_read_stop, file ../deps/uv/src/unix/stream.c, line 1319.
Abort trap: 6
I have no idea what can cause this. Do I miss something? Is my config correct?
Thanks.
I am trying optimization level 2 and my sprite is losing some trailing icons. It works fine with optimization level 1. Any help will be appreciated.
Hi,
I just downloaded a fresh copy of yeoman. When I build using grunt, I see that all my images have been converted and their file names have been renamed.
However, the references in the html file do not reference the new names.
Any idea why?
imagemin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/img',
src: '{,*/}*.{png,jpg,jpeg}',
dest: '<%= yeoman.dist %>/img'
}]
}
},
not a big deal but there is no readme on the npm site ;)
https://npmjs.org/package/grunt-contrib-imagemin
Currently the saved file space is shown for a single file, which is nice, but would it be possible to show also the complete reduction for the given files object?
I realize it's probably an early version, but for reference this is the sort of thing I do in my current imagemin setup. It's pretty similar to the #devel grunt-contrib-copy task.
imagemin: {
dist: {
options: {
cwd: 'app/public/img'
processName = function(name){
// transform image <img>.png to <img>-min.png
}
},
files: {
'temp/staging/': ['**/*.png', '**/*.jpg']
}
}
}
When I use this:
dist: {
options: {
optimizationLevel: 3
},
files: {
'../dist/img': ['../images/**/*.*']
}
}
It won't copy my jpg images and if I specify an jpg like this:
dist: {
options: {
optimizationLevel: 3
},
files: {
'../dist/img/email.jpg': ['../images/email.jpg*']
}
}
I get the following error:
Fatal error: ENOENT, no such file or directory 'c:\proj\dist\img\email.jpg'
Currently unable to install grunt-contrib-imagemin, looks like the jpegtran-bin dependency is borked.
Should this be logged here, or with the jpegtran-bin project?
Error: Command failed: configure: error: no nasm (Netwide Assembler) found
at ChildProcess.exithandler (child_process.js:540:15)
at ChildProcess.EventEmitter.emit (events.js:99:17)
at maybeClose (child_process.js:638:16)
at Process._handle.onexit (child_process.js:680:5)
npm ERR! [email protected] postinstall: node pre-build.js
npm ERR! sh "-c" "node pre-build.js"
failed with 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is most likely a problem with the jpegtran-bin package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node pre-build.js
npm ERR! You can get their info via:
npm ERR! npm owner ls jpegtran-bin
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 2.6.18-308.el5
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! cwd /home/jdaihl/projects/madmen-web-wl
npm ERR! node -v v0.8.15
npm ERR! npm -v 1.1.66
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/jdaihl/projects/madmen-web-wl/npm-debug.log
npm ERR! not ok code 0
This is what I've got:
> [email protected] postinstall /media/sf_D_DRIVE/Sites/_kud/happy-plan/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin
> node build.js
{ [Error: Command failed: ./configure: line 1246: cannot create temp file for here-document: Text file busy
./configure: line 1257: cannot create temp file for here-document: Text file busy
./configure: line 1291: cannot create temp file for here-document: Text file busy
./configure: line 1443: cannot create temp file for here-document: Text file busy
./configure: line 1448: cannot create temp file for here-document: Text file busy
./configure: line 1453: cannot create temp file for here-document: Text file busy
./configure: line 1458: cannot create temp file for here-document: Text file busy
./configure: line 1463: cannot create temp file for here-document: Text file busy
./configure: line 1745: cannot create temp file for here-document: Text file busy
sed: couldn't open file conftest.sed: No such file or directory
rm: cannot remove 'conftest.sed': No such file or directory
./configure: line 1843: cannot create temp file for here-document: Text file busy
./configure: line 1898: cannot create temp file for here-document: Text file busy
./configure: line 1903: cannot create temp file for here-document: Text file busy
./configure: line 2029: cannot create temp file for here-document: Text file busy
./configure: line 2043: cannot create temp file for here-document: Text file busy
./configure: line 2437: cannot create temp file for here-document: Text file busy
./configure: line 2441: cannot create temp file for here-document: Text file busy
configure: error: C compiler cannot create executables
See `config.log' for more details.
./configure: line 6: cannot create temp file for here-document: Text file busy
./configure: line 29: cannot create temp file for here-document: Text file busy
./configure: line 58: cannot create temp file for here-document: Text file busy
] killed: false, code: 77, signal: null }
config like this:
imagemin: {
build: {
src: 'img/npm.png',
dest: 'imgmin/npm.png'
}
}
Upgrading my environment to 0.4.x and have installed the latest pre-release version:
When I try to test the task: grunt imagemin , I get the following error:
node.js:617
var fn = runInThisContext(source, this.filename, true);
^
Warning: Cannot read property 'message' of undefined Use --force to continue.
Aborted due to warnings.
My gruntfile task is as follows:
imagemin: {
release: {
options: {
optimizationLevel: 0
},
files: {
expand: true,
src: ['assets/img/*.*'],
dest: 'assets/img/'
}
}
},
Any help is greatly appreciated. Thx!
If you attempt to install this into a directory that has a space, the installation will fail. See the following failure (fyi - I moved to another directory that had no space - and it installed fine):
> [email protected] postinstall /Projects/DT Site/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin
> node pre-build.js
1) jpegtran should return path to jpegtran binary
1) OptiPNG should return path to OptiPNG binary
2) jpegtran should successfully proxy jpegtran
2) OptiPNG should successfully proxy OptiPNG
3) jpegtran should minify a .jpg
4) jpegtran "after all" hook
✖ 4 of 3 tests failed:
1) jpegtran should return path to jpegtran binary:
AssertionError: false == true
at args (/Projects/DT Site/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/test/test-jpegtran-path.js:18:4)
at ChildProcess.exithandler (child_process.js:544:7)
at ChildProcess.EventEmitter.emit (events.js:99:17)
at maybeClose (child_process.js:638:16)
at Process._handle.onexit (child_process.js:680:5)
2) jpegtran should successfully proxy jpegtran:
AssertionError: false == true
at args (/Projects/DT Site/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/test/test-jpegtran-path.js:27:4)
at ChildProcess.exithandler (child_process.js:544:7)
at ChildProcess.EventEmitter.emit (events.js:99:17)
at maybeClose (child_process.js:638:16)
at Process._handle.onexit (child_process.js:680:5)
3) jpegtran should minify a .jpg:
Error: ENOENT, no such file or directory 'test/minified.jpg'
at Object.fs.statSync (fs.js:524:18)
at /Projects/DT Site/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/test/test-jpegtran-path.js:42:20
at ChildProcess.exithandler (child_process.js:544:7)
at ChildProcess.EventEmitter.emit (events.js:99:17)
at maybeClose (child_process.js:638:16)
at Process._handle.onexit (child_process.js:680:5)
3) OptiPNG should minify a .png
4) OptiPNG "after all" hook
4) jpegtran "after all" hook:
Error: ENOENT, no such file or directory 'test/minified.jpg'
at Object.fs.unlinkSync (fs.js:582:18)
at Context.binPath (/Projects/DT Site/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/test/test-jpegtran-path.js:11:6)
at Hook.Runnable.run (/Projects/DT Site/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/node_modules/mocha/lib/runnable.js:213:32)
at next (/Projects/DT Site/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/node_modules/mocha/lib/runner.js:243:10)
at Runner.hook (/Projects/DT Site/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/node_modules/mocha/lib/runner.js:254:5)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
Fetching http://downloads.sourceforge.net/project/libjpeg-turbo/1.2.90%20%281.3beta1%29/libjpeg-turbo-1.2.90.tar.gz...
✖ 4 of 3 tests failed:
1) OptiPNG should return path to OptiPNG binary:
AssertionError: false == true
at args (/Projects/DT Site/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin/test/test-optipng-path.js:18:4)
at ChildProcess.exithandler (child_process.js:544:7)
at ChildProcess.EventEmitter.emit (events.js:99:17)
at maybeClose (child_process.js:638:16)
at Process._handle.onexit (child_process.js:680:5)
2) OptiPNG should successfully proxy OptiPNG:
AssertionError: false == true
at args (/Projects/DT Site/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin/test/test-optipng-path.js:27:4)
at ChildProcess.exithandler (child_process.js:544:7)
at ChildProcess.EventEmitter.emit (events.js:99:17)
at maybeClose (child_process.js:638:16)
at Process._handle.onexit (child_process.js:680:5)
3) OptiPNG should minify a .png:
Error: ENOENT, no such file or directory 'test/minified.png'
at Object.fs.statSync (fs.js:524:18)
at /Projects/DT Site/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin/test/test-optipng-path.js:43:20
at ChildProcess.exithandler (child_process.js:544:7)
at ChildProcess.EventEmitter.emit (events.js:99:17)
at maybeClose (child_process.js:638:16)
at Process._handle.onexit (child_process.js:680:5)
4) OptiPNG "after all" hook:
Error: ENOENT, no such file or directory 'test/minified.png'
at Object.fs.unlinkSync (fs.js:582:18)
at Context.binPath (/Projects/DT Site/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin/test/test-optipng-path.js:11:6)
at Hook.Runnable.run (/Projects/DT Site/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin/node_modules/mocha/lib/runnable.js:213:32)
at next (/Projects/DT Site/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin/node_modules/mocha/lib/runner.js:243:10)
at Runner.hook (/Projects/DT Site/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin/node_modules/mocha/lib/runner.js:254:5)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
Fetching http://downloads.sourceforge.net/project/optipng/OptiPNG/optipng-0.7.4/optipng-0.7.4.tar.gz...
Done in /Projects/DT Site/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/libjpeg-turbo-1.2.90
Building libjpeg-turbo...
Done in /Projects/DT Site/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin/optipng-0.7.4
Building OptiPNG...
/Projects/DT Site/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin/build.js:64
throw err;
^
Error: Command failed:
at ChildProcess.exithandler (child_process.js:540:15)
at ChildProcess.EventEmitter.emit (events.js:99:17)
at maybeClose (child_process.js:638:16)
at Process._handle.onexit (child_process.js:680:5)
npm ERR! [email protected] postinstall: `node pre-build.js`
npm ERR! `sh "-c" "node pre-build.js"` failed with 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is most likely a problem with the optipng-bin package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node pre-build.js
npm ERR! You can get their info via:
npm ERR! npm owner ls optipng-bin
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 12.3.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "grunt-contrib-imagemin" "-D"
npm ERR! cwd /Projects/DT Site
npm ERR! node -v v0.8.14
npm ERR! npm -v 1.1.65
npm ERR! code ELIFECYCLE
/Projects/DT Site/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/build.js:78
throw err;
^
Error: Command failed: ./configure: line 311: test: /Projects/DT: binary operator expected
./configure: line 311: test: /Projects/DT: binary operator expected
./configure: line 311: test: /Projects/DT: binary operator expected
./configure: line 311: test: /Projects/DT: binary operator expected
./configure: line 311: test: /Projects/DT: binary operator expected
./configure: line 311: test: /Projects/DT: binary operator expected
configure: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used.
./configure: line 1697: conftest.file: No such file or directory
ls: ./configure: No such file or directory
ls: conftest.file: No such file or directory
configure: error: ls -t appears to fail. Make sure there is not a broken
alias in your environment
configure: error: newly created file is older than distributed files!
Check your system clock
at ChildProcess.exithandler (child_process.js:540:15)
at ChildProcess.EventEmitter.emit (events.js:99:17)
at maybeClose (child_process.js:638:16)
at Process._handle.onexit (child_process.js:680:5)
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Projects/DT Site/npm-debug.log
npm ERR! not ok code 0
node 0.8.20, grunt 0.4 on OS X. Installing 0.1.2 gives me this error message.
Installing 0.1.1 still works fine.
I can't run imagemin over a directory with a large number of files in it.
This is the relevant section of my Gruntfile
:
imagemin:
prod:
options:
optimizationLevel: 3,
files: [
expand: true
cwd: './app/images'
src: ['./**/*.png', './**/*.jpg']
dest: './dist/images'
]
dev:
options:
optimizationLevel: 1,
files: [
expand: true
cwd: './app/'
src: ['images/**/*.png', 'images/**/*.jpg']
dest: './temp/images'
]
There is a subdirectory under app/images which contains 124 .jpg-files. As a test I removed about 100 of them and tried again and the job worked.
I need someone to help update this plugin to work with grunt 0.4.0rc5.
I had to revert the whole file src-dest mappings implicit iteration abstraction per gruntjs/grunt#606, and once again, multi tasks have to iterate over this.files
manually. In addition, there's a new this.filesSrc
array that contains a reduced, uniqued set of all matched src
files in case the task is read-only and only cares about source files.
See:
this.filesSrc
array.this.files
array.Notes:
nonull
in addition to src
to tell grunt to keep patterns or filepaths that don't actually match files. Because of this, the task shouldn't explode if a nonexistent src
filepath is encountered. I handle this in the grunt-contrib-concat by warning if not grunt.file.exists
but not failing the task.Guidelines for updating / publishing this plugin:
"*"
)README.md
file via grunt.node_modules
, run npm cache clean
and re-run npm install
to test.--tag=master
(not latest
)
grunt.registerTask('production', ['concat', 'copy', 'uglify', 'cssmin', 'imagemin', 'zip', 'clean']);
the imagemin task completes and all following tasks get ignored. In this case imagemin returns on success and zip and clean won't get executed.
Tasks work independently.
using:
"devDependencies": {
"grunt": "~0.4.0",
"grunt-contrib-concat": "~0.1.2rc6",
"grunt-contrib-imagemin": "~0.1.2",
"grunt-contrib-jshint": "~0.1.1rc6",
"grunt-contrib-uglify": "~v0.1.1rc6",
"grunt-zip": "~0.3.0",
"grunt-contrib-copy": "~0.4.0",
"grunt-contrib-cssmin": "~0.4.1",
"grunt-contrib-clean": "~0.4.0"
}
Hi,
Below is part of my Grunt file where I'm specifying options for my image optimisation.
Three issues:
grunt imagemin
I'm told the image is already optimised? I've tried with multiple images of varying sizes and i just can't seem to get any image to not show this message? I've tried setting the optimizationLevel
property to 7 (the highest I can go) but no difference?dist
and not the dev
settings?Thanks.
imagemin: {
dist: {
options: {
optimizationLevel: 7,
progressive: true
},
files: {
//'./app/images/': './app/images/**/*.jpg'
'./app/images/test-min.jpg': './app/images/test.jpg',
'./app/images/car-min.jpg': './app/images/car.jpg'
}
},
dev: {
options: {
optimizationLevel: 0
},
files: {
//'./app/images/': './app/images/**/*.jpg'
'./app/images/test-min.jpg': './app/images/test.jpg',
'./app/images/car-min.jpg': './app/images/car.jpg'
}
}
}
I'm using node bower and yeoman behind a corporate proxy ...
But i've got this issue with the install of grunt-contrib-imagemin after the tests :
stream.js:94
throw er; // Unhandled stream error in pipe.
^
Error: connect ETIMEDOUT
at errnoException (net.js:901:11)
at Object.afterConnect as oncomplete
stream.js:94
throw er; // Unhandled stream error in pipe.
^
Error: connect ETIMEDOUT
at errnoException (net.js:901:11)
at Object.afterConnect as oncomplete
npm ERR! weird error 8
npm ERR! not ok code 0
I understand that the task should at least copy image from dest to src. During my dev process, I just use a copy task to deploy my images. For production, I would like to call just my imagemin:dist
below
imagemin: {
dist: {
options: {
optimizationLevel: 7,
progressive: true
},
files: {
'<%= happyPlan.build.assets.images %>': '<%= happyPlan.src.assets.images %>/**/*',
'<%= happyPlan.build.medias %>': '<%= happyPlan.build.medias %>/**/*'
}
}
}
But it seems this only copy images this task can optimize (2 of 22). Am I wrong ? If yes what am I doing wrong ? (my stupid copy task equivalent copy correctly all my images)
Thanks
Hi,
My test repo can be found here: https://github.com/Integralist/Grunt-Boilerplate
The documentation doesn't show any way to just target a folder and have all images within the folder compressed and exported into a separate folder. At the moment you have to manually reference each individual image which isn't very useful (especially if you have a folder full of images).
One other item worth looking at as well is the ability to optimise the images and have them overwrite the original images (e.g. not exported into a separate folder).
If either of these features are available then please can you explain how to use them, and if not then I would ask they be added in the near future as I currently couldn't imagine users hard coding in each and every image they have into their Gruntfile?
Thanks.
On Mac OS X with node v0.10.2, grunt unexpectedly exits after printing
Running "imagemin:dist" (imagemin) task
$
My Gruntfile was set up to run it as:
grunt.initConfig({
//...
imagemin: {
dist: {
options: {
optimizationLevel: 0
},
files: {
'client/images/beta.png': 'build/beta.png'
}
}
}
//...
});
This was the result of the npm install command:
$ npm install grunt-contrib-imagemin --save-dev
npm http GET https://registry.npmjs.org/grunt-contrib-imagemin
npm http 304 https://registry.npmjs.org/grunt-contrib-imagemin
npm http GET https://registry.npmjs.org/optipng-bin
npm http GET https://registry.npmjs.org/filesize
npm http GET https://registry.npmjs.org/jpegtran-bin
npm http 304 https://registry.npmjs.org/jpegtran-bin
npm http 304 https://registry.npmjs.org/filesize
npm http 304 https://registry.npmjs.org/optipng-bin
npm http GET https://registry.npmjs.org/colors
npm http GET https://registry.npmjs.org/which
npm http 304 https://registry.npmjs.org/colors
npm http 304 https://registry.npmjs.org/which
> [email protected] postinstall /Users/anthony/Sites/graph/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin
> node build.js
> [email protected] postinstall /Users/anthony/Sites/graph/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin
> node build.js
OptiPNG rebuilt successfully
libjpeg-turbo rebuilt successfully
[email protected] node_modules/grunt-contrib-imagemin
├── [email protected]
├── [email protected] ([email protected], [email protected])
└── [email protected] ([email protected], [email protected])
How can I batch compress all images within a folder (keeping the original names)?
I've tried
files: {
'img/*.jpg': 'img/*.jpg'
}
but that didn't work.
It would be useful if subdirs of a source directory could be preserved. For instance, if I match:
files: { 'dest/', [ 'src/**/*.jpg' ] }
Then src/foo/bar.jpg would be saved as dest/foo/bar.jpg.
Perhaps grunt.file.recurse
is the answer?
Ref #19
All,
I'm having issues to install grunt-contrib-imagemin on my linux box. It works perfectly on my mac, but fails on my hudson box. Any help is appreciated.
[gmaggess@slc02ixa client]$ npm install grunt-contrib-imagemin --save-dev
...
> [email protected] postinstall /scratch/gmaggess/workspace/dash/client/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin
> node pre-build.js
> [email protected] postinstall /scratch/gmaggess/workspace/dash/client/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin
> node pre-build.js
✖ 4 of 3 tests failed:
1) jpegtran should return path to jpegtran binary:
AssertionError: false == true
at /scratch/gmaggess/workspace/dash/client/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/test/test-jpegtran-path.js:18:4
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:451:12)
2) jpegtran should successfully proxy jpegtran:
AssertionError: false == true
at /scratch/gmaggess/workspace/dash/client/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/test/test-jpegtran-path.js:27:4
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Process.ChildProcess._handle.onexit (child_process.js:802:5)
3) jpegtran should minify a .jpg:
Error: ENOENT, no such file or directory 'test/minified.jpg'
at Object.fs.statSync (fs.js:684:18)
at /scratch/gmaggess/workspace/dash/client/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/test/test-jpegtran-path.js:42:20
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:451:12)
4) jpegtran "after all" hook:
Error: ENOENT, no such file or directory 'test/minified.jpg'
at Object.fs.unlinkSync (fs.js:760:18)
at Context.<anonymous> (/scratch/gmaggess/workspace/dash/client/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/test/test-jpegtran-path.js:11:6)
at Hook.Runnable.run (/scratch/gmaggess/workspace/dash/client/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/node_modules/mocha/lib/runnable.js:213:32)
at next (/scratch/gmaggess/workspace/dash/client/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/node_modules/mocha/lib/runner.js:243:10)
at Object._onImmediate (/scratch/gmaggess/workspace/dash/client/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/node_modules/mocha/lib/runner.js:254:5)
at processImmediate [as _immediateCallback] (timers.js:330:15)
pre-build test failed, compiling from source...
Fetching http://downloads.sourceforge.net/project/libjpeg-turbo/1.2.90%20%281.3beta1%29/libjpeg-turbo-1.2.90.tar.gz...
✖ 4 of 3 tests failed:
1) OptiPNG should return path to OptiPNG binary:
AssertionError: false == true
at /scratch/gmaggess/workspace/dash/client/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin/test/test-optipng-path.js:18:4
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:451:12)
2) OptiPNG should successfully proxy OptiPNG:
AssertionError: false == true
at /scratch/gmaggess/workspace/dash/client/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin/test/test-optipng-path.js:27:4
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Process.ChildProcess._handle.onexit (child_process.js:802:5)
3) OptiPNG should minify a .png:
Error: ENOENT, no such file or directory 'test/minified.png'
at Object.fs.statSync (fs.js:684:18)
at /scratch/gmaggess/workspace/dash/client/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin/test/test-optipng-path.js:43:20
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Process.ChildProcess._handle.onexit (child_process.js:802:5)
4) OptiPNG "after all" hook:
Error: ENOENT, no such file or directory 'test/minified.png'
at Object.fs.unlinkSync (fs.js:760:18)
at Context.<anonymous> (/scratch/gmaggess/workspace/dash/client/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin/test/test-optipng-path.js:11:6)
at Hook.Runnable.run (/scratch/gmaggess/workspace/dash/client/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin/node_modules/mocha/lib/runnable.js:213:32)
at next (/scratch/gmaggess/workspace/dash/client/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin/node_modules/mocha/lib/runner.js:243:10)
at Object._onImmediate (/scratch/gmaggess/workspace/dash/client/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin/node_modules/mocha/lib/runner.js:254:5)
at processImmediate [as _immediateCallback] (timers.js:330:15)
pre-build test failed, compiling from source...
Fetching http://downloads.sourceforge.net/project/optipng/OptiPNG/optipng-0.7.4/optipng-0.7.4.tar.gz...
Done in /tmp/optipng-0.7.4
Building OptiPNG...
OptiPNG rebuilt successfully
Done in /tmp/libjpeg-turbo-1.2.90
Building libjpeg-turbo...
/scratch/gmaggess/workspace/dash/client/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin/build.js:78
throw err;
^
Error: Command failed: configure: error: installation or configuration problem: assembler cannot create object files.
at ChildProcess.exithandler (child_process.js:637:15)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:451:12)
npm ERR! weird error 8
npm ERR! not ok code 0
Cheers,
The following test case:
yo webapp
grunt build
Produces this error:
Warning:
C:\Users\Jahvi\Desktop\app\node_modules\grunt-contrib-compass\node_modules\tmp\lib\tmp.js:261
throw err;
^
Error: ENOENT, no such file or directory 'C:\Users\Jahvi\Desktop\app\dist\images\adventure-cat.png'
at Object.fs.statSync (fs.js:684:18)
at processed (C:\Users\Jahvi\Desktop\app\node_modules\grunt-contrib-imagemin\tasks\imagemin.js:80:43)
at C:\Users\Jahvi\Desktop\app\node_modules\grunt-contrib-imagemin\tasks\imagemin.js:127:29
at callDone (C:\Users\Jahvi\Desktop\app\node_modules\grunt\lib\grunt\util.js:147:5)
at ChildProcess.<anonymous> (C:\Users\Jahvi\Desktop\app\node_modules\grunt\lib\grunt\util.js:186:5)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:465:12) Use --force to continue.
Aborted due to warnings.
It seems to work fine with JPG/JPEG images though, I downgraded to v0.2.0 and got the same error, it works fine on v0.1.0 though.
I'm running Win7 64bits
I'm running the following set of instructions:
imagemin: {
dist: {
options: {
optimizationLevel: 1
},
files: {
'public/images/**/*.*': ['app/images/**/*.*', 'vendor/images/**/*.*']
}
}
}
There are only 2 png files within vendor/images (bootstrap icons).
The result I'm getting is:
Running "imagemin:dist" (imagemin) task
Error: * Processing: vendor/images/glyphicons-halflings.png
469x159 pixels, 2x8 bits/pixel, grayscale+alpha
Stripping metadata...
The output file exists. Rerun OptiPNG with -backup enabled
Error: Can't overwrite the output file
not sure why I'm getting the error. I initially thought it had something to do with the generated images, but clearing the public/image directory does not help.
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.