imagegulpsrc

gulp 5 src() make the images format unsupported


I have some images in my project that I want to compress them using gulp

But first I want to move them to the dist folder so I made this simple task

function test(){
    return src("src/images/*").pipe(dest("dist"))
}

this worked fine before in gulp@4.0.2.

But now using gulp@5.0.0 the images moved to the folder but they refuse to render in html! and I can't open them anymore look at the screenshot (I'm using Microsoft Photo)

enter image description here

Also, this is using the VS code enter image description here

Looks like src() changed the imaged format and thus destroyed it!

Anyone could help with this?


Solution

  • you may try adding { encoding: false } :

    function test(){
        return src("src/images/*", { encoding: false }).pipe(dest("dist"))
    }
    

    I was having issues copying and serving fonts when I upgraded to gulp 5:

    Failed to decode downloaded font

    OTS parsing error: incorrect file size in WOFF header

    https://github.com/gulpjs/gulp/issues/2797

    Gulp options:

    https://gulpjs.com/docs/en/api/src#options

    encoding: when false, file contents are treated as binary