Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrupted image .jpg and .png #388

Open
dovecancode opened this issue Aug 26, 2024 · 3 comments
Open

Corrupted image .jpg and .png #388

dovecancode opened this issue Aug 26, 2024 · 3 comments

Comments

@dovecancode
Copy link

Hi,

I'm quite new to using gulp-imagemin. I don't have any issues with minifying SVGs, but I've noticed that when it comes to .jpg and .png files, the images appear corrupted after running the npx gulp command.

here is my gulpfile.js:

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

function taskImageMin() {
  return gulp
    .src('src/images/*.{jpg,png}')
    .pipe(imagemin())
    .on('data', function (file) {
      console.log('File processed:', file.path)
    })
    .pipe(gulp.dest('dist/images'))
}

export default taskImageMin

the output is on th left side and its corrupted or something like that

image

@etherealHero
Copy link

I also encountered this problem. What helped me was downgrading the imagemin version to 7.1.0. Accordingly, my package.json looks like this:

  "devDependencies": {
    "browser-sync": "^3.0.2",
    "del": "^6.0.0",
    "gulp": "^4.0.2",
    "gulp-htmlmin": "^5.0.1",
    "gulp-imagemin": "^7.1.0",
    "gulp-newer": "^1.4.0",
    "gulp-sass": "^5.0.0",
    "gulp-size": "^4.0.1",
    "gulp-sourcemaps": "^3.0.0",
    "sass": "^1.37.5"
  }

@Applelo
Copy link

Applelo commented Sep 12, 2024

Try to use encoding false, it solves my problem with corrupted files

gulp.src(paths.images.src, {encoding: false})

imagemin/imagemin#418 (comment)

@xshapira
Copy link

xshapira commented Nov 9, 2024

Try to use encoding false, it solves my problem with corrupted files

gulp.src(paths.images.src, {encoding: false})

imagemin/imagemin#418 (comment)

Thank you! Works like a charm 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants