Last 12 weeks · 0 commits
4 of 6 standards met
After a recent update to Gulp 5 and gulp-imagemin 9.1.0, the gulp series does not wait for imagemin to complete before moving on to another stream in the pipe. Does anyone have any ideas?
Repository: sindresorhus/gulp-imagemin. Description: Minify PNG, JPEG, GIF and SVG images Stars: 1905, Forks: 156. Primary language: JavaScript. Languages: JavaScript (100%). License: MIT. Topics: compress-images, gulp-plugin, imagemin, javascript, minify-images, nodejs. Latest release: v9.2.0 (3mo ago). Open PRs: 0, open issues: 23. Last activity: 3mo ago. Community health: 85%. Top contributors: sindresorhus, kevva, XhmikosR, zcei, phated, bdukes, simplydenis, tjbulick, bfred-it, olets and others.
JavaScript
Issue: Images (e.g., PNG, JPG) were being corrupted during optimization, likely due to aggressive compression settings or unhandled errors in the plugin. I found out this issue and observed in a custom implementation and potentially the main plugin. Fixes: Safer Defaults: Adjusted plugin settings to reduce corruption risk: : Set (from a lower value) and enabled for better compatibility. : Set to avoid over-compression of PNGs. : Reduced to prevent aggressive optimization. : Limited plugins to preserve and avoid unintended changes. Error Handling: Added try-catch blocks around to catch and log optimization errors, returning the original file if optimization fails to prevent corruption. Integrity Check: Implemented a basic size check (skipping files < 100 bytes) to detect and avoid corrupt outputs. Enhanced Logging: Improved verbose output with for better debugging, showing success, warnings, and errors. Testing: Tested on April 29, 2025, with a sample set of PNG, JPG, GIF, and SVG files. Ran with to verify logging and ensured optimized images rendered correctly in a browser and image viewer. Confirmed no corruption by comparing original and optimized files using command (e.g., ). Impact: Reduces the likelihood of image corruption during optimization. Maintains reasonable file size reduction while prioritizing integrity. Users can enable verbose mode () to debug issues. Additional Notes: The changes are backward-compatible but may result in slightly larger file sizes due to safer settings. Consider adding unit tests for the integrity check and error handling if the project supports it (e.g., Mocha). Open to feedback on adjusting default settings or adding configuration options for advanced users. Checklist: [x] Code compiles successfully. [x] Tests pass (if applicable). [x] Documentation updated (if needed, e.g., README or plugin docs). [x] Changes reviewed locally. Please review and let me know if further adjustments are needed!
Safari finally support webp exention. Now all browsers support progressive format, but there is no way to conveniently optimize it. imagemin-webp can convert to webp, can`t optimized webp. Sorry for duplicate #205, but perhaps other defaults are relevant now, not the same as four years ago? I think now webp more important than gif. If you think this is still not default, please at least add webp to validExtensions to be able to optimize this format.