sindresorhus / gulp-imagemin

Minify PNG, JPEG, GIF and SVG images
MIT License
1.9k stars 157 forks source link

Corrupt output files #383

Closed flaunder007 closed 4 months ago

flaunder007 commented 4 months ago

Task:

import gulp from 'gulp';
import imagemin from 'gulp-imagemin';

const rastr = async () => (
    gulp.src('src/img/**/*.(jpg|jpeg|png|svg|ico)')
        .pipe( imagemin({verbose: true}))
        .pipe(gulp.dest('build/images'))
);

export default rastr

gulpfile.js

import {parallel, series} from "gulp";
import rastr from "./tasts/rastr.js";
...
export const img = rastr
...

After i start "gulp img" it geave me

PS D:\7> gulp img
[13:31:26] Using gulpfile D:\7\gulpfile.js
[13:31:26] Starting 'img'...
[13:31:26] Finished 'img' after 8.73 ms
gulp-imagemin: ✔ mine_bg.jpg (already optimized)
gulp-imagemin: ✔ og.jpg (already optimized)
gulp-imagemin: ✔ sprite.svg (saved 25 B - 0.2%)
gulp-imagemin: ✔ video_bg.jpg (already optimized)
gulp-imagemin: Minified 1 image (saved 25 B - 0.2%)

so it optimize only svg, but all ather files (whitch, by the way, are not optimized) turned out corrupted, and cant be shown. image

I run this in Windows 11.

flaunder007 commented 4 months ago

node v20.12.2

gulp CLI version: 3.0.0 Local version: 5.0.0

imagemin "gulp-imagemin": "^9.0.0",

madjacky commented 4 months ago

add ancoding: false to src like this:

return src([`${paths.imagesFolder.src}/**/**.{jpg,jpeg,png,svg}`], { encoding: false })
flaunder007 commented 4 months ago

It worked, thanks a lot!