zauni / pngmin Goto Github PK
View Code? Open in Web Editor NEWGrunt plugin to compress png images with pngquant.
License: MIT License
Grunt plugin to compress png images with pngquant.
License: MIT License
Dear developers... :)
I'm getting a fatal error when grunting with this tool. :(
MY GRUNT CODE:
pngmin: {
files: {
src: '<%= paths.dist %><%= pkg.widget.name %>-sprite.png',
dest: '<%= paths.dist %><%= pkg.widget.name %>-sprite.png'
}
}
MY TERMINAL OUTPUT:
Running "pngmin:files" (pngmin) task
Verifying property pngmin.files exists in config...OK
Files: ../../distribution/sdk-demo-widget-sprite.png -> ../../distribution/sdk-demo-widget-sprite.png
Options: binary="bin/pngquant", concurrency=4, colors=256, ext="-fs8.png", force=false, speed=3, iebug=false, transbug=false
Reading ../../distribution/sdk-demo-widget-sprite.png...OK
Writing /tmp/tmp-8218a72nlww.png...OK
Fatal error: Reduce of empty array with no initial value
Any idea on how I can correct this?
-Ryan
p.s. I've also installed pngquant as well...
pngquant, version 1.0 of 5 April 2002, by Greg Roelofs.
Compiled with libpng 1.2.46; using libpng 1.2.49.
Compiled with zlib 1.2.3.4; using zlib 1.2.7.
Hi!
You are already reverting the optimization for images that would get bigger by pngmin
Optimization would increase file size by 1 % so optimization was skipped on file xyz.png
For me it would make sense if you also revert the optimization for images where the optimization saved 0%
Optimized xyz.png [saved 0 % - 622 B → 622 B]
because otherwise these files are still recognized by git as "modified" because the timestamp changed.
Hi, thanks for the library! I'll work on a PR to address this issue but for now I'll submit the issue in case there's any delay or if my PR isn't suitable.
The problem:
I found that pngquant
was failing to execute because I didn't have the libpng-dev
package installed (Alpine linux docker container). I noticed this because I would see the following output with no explanation at all, so I had no insight at all on why it was failing:
Running "pngmin:sprites" (pngmin) task
Overall savings: 0 % | 0 B
Done.
After some digging, I found this was using pngquant-bin
so I ran ./node_modules/.bin/pngquant
directly, which resulted in a very long error (expand to see full contents):
error Error: Error loading shared library libpng16.so.16: No such file or directory (needed by /var/www/html/node_modules/pngquant-bin/vendor/pngquant)
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_IHDR: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_create_write_struct: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_write_info: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_get_user_chunk_ptr: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_write_fn: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_keep_unknown_chunks: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_destroy_write_struct: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_gray_to_rgb: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_get_IHDR: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_read_image: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_option: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_get_rowbytes: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_compression_mem_level: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_destroy_read_struct: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_get_iCCP: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_create_info_struct: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_interlace_handling: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_read_user_chunk_fn: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_write_end: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_get_gAMA: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_write_image: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_PLTE: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_get_error_ptr: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_read_fn: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_get_cHRM: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_read_info: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_gAMA: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_get_valid: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_unknown_chunks: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_filler: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_expand: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_filter: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_read_update_info: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_init_io: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_sRGB: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_create_read_struct: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_error: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_get_io_ptr: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_strip_16: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_tRNS: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_get_header_ver: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_compression_level: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_set_packing: symbol not found
Error relocating /var/www/html/node_modules/pngquant-bin/vendor/pngquant: png_read_end: symbol not found
Proposed solution:
IMHO, a failure should also result in the grunt
command failing as well. On one hand, since this is a bug, it should be fixed in the same major version. However, failing a command that previously was working is IMHO a very serious semver violation (despite resulting from a bug fix). So, I propose addressing this in two simple phases:
console.error
. Then, add an option like options.failOnError
which defaults to false
for [email protected]
. If[email protected]
and default this option to true
(and then document this change in the README.md
release history).Please add an option to enable dithering.
grunt.util.spawn({
cmd: options.binary,
args: args
}, function(error, result, code) {
我运行的时候pngmin.js这个地方报错,报错内容如标题,mac系统
We could reduce the file size even further if we would use optipng for lossless compression.
How about changing dependency to pngquant-bin (https://github.com/imagemin/pngquant-bin)? Seems to be active and has linux support, it's pretty much the same as your own package.
Hi,
The “watch” task doesn't work in the new 0.6.3 version. The plugin freezes after some images are added. If I run “watch” via a direct command, it processes 3-4 images and stops working, though there are more images left.
http://screen.w3.ua/Nov14/364702125.png
In the 0.6.1 version everything worked well. Could you help me out with this?
I came up against this error when writing the files:
Fatal error: spawn EACCES
When I run the task with --verbose
I see the task lists all the files that I would expect for it to operate on, and then it outputs this (I tuned concurrency to 1 just for debugging):
Options: binary="/Users/jrz/labs/facebook-trove/node_modules/grunt-pngmin/node_modules/node-pngquant-bin/vendor/osx/pngquant", concurrency=1, colors=256, ext=".png", quality=null, force, speed=3, iebug=false, transbug=false
Reading client/images/anon-follow.png...OK
Writing /var/folders/gf/0fyyc1ms35b2dwbp1m_xv2kc0000gp/T/tmp-19224rrh5f9c.png...OK
Fatal error: spawn EACCES
I checked the permissions of the tmp folder and they seem be good (700):
jrz@jrz ~/l/facebook-trove [grunt-imagemin]> ls -halG /var/folders/gf/0fyyc1ms35b2dwbp1m_xv2kc0000gp/T
total 12000
drwx------ 235 jrz staff 7.8K Jul 2 10:05 .
Do you have any ideas about what I could be doing wrong?
Hello,
I found a problem with some PNG files. I have a many folders with PNG files and all of them are exported from photoshop by same method. But some of them are not affected by pngmin task. Do you know, where may be a problem? File "auto.png" (car) is ok, but "dum.png" (house) in same location is ignored. I tryied to rename it, crop and resave, but without success.
Thank You
Tom
Hello,
today I updated plugin to latest version and I found a problem. The grunt task will freeze after minimizes some images. This is not dependent on some specific image, it will stop after for approx 12 images (folder contains 40), but if I have only one inside the folder, it freezes too with message "Process finished with exit code 0". Version 0.6.2 is working fine. (If You remember, I reported problem with images with version 0.6.1).
(If it helps You, our task contains these other plugins: sourcemap, clen, compress, concat, copy, uglify, yuidoc, ffmpeg, open, rename, replace and Your pngmin)
Bye,
Tomas
It would be nice if one would get an overview of how much the compression saved on all the files together.
I'm running pngmin on all files in a directory and grunt is aborting:
pngmin: {
default_options: {
options: {
binary: '/usr/bin/pngquant',
ext: '.png',
force: true
},
files: [
{
src: 'build/supercar/images/*.png',
dest: 'build/supercar/images/'
}
]
}
}
Running "pngmin:default_options" (pngmin) task
Warning: spawn EMFILE Use --force to continue.
Aborted due to warnings.
However on further inspection I'm noticing that the files are actually being optimized even though grunt aborts. There are about 296 files in the directory and there are a few sub-directories, less than half are .png. I notices if I delete a bunch of files from the directory I don't have the issue. I tried removing sub-directories first, but still had the problem so it possibly seems to be related to the number of files.
Please update the peerDependency listed in the package.json to support grunt 1.0.1
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.