0

I cant minify my images because of thumbs.db file, when I try to minify my images, I get a permission error which looks like this:

Error: EPERM: operation not permitted, open 'C:\Users\Pc\Desktop\template\dist\img\Thumbs.db'

I get it why it does this but I don't know how to prevent this.

Edit 1: gulp snippet

gulp.task('imageMin', () =>
  gulp.src('src/img/*')
      .pipe(imagemin())
      .pipe(gulp.dest('dist/img'))
);
3
  • Have you tried running with --verbose? Looking through gulp-imagemin's source a bit it seems like it should skip any files that aren't a recognized image type. So, maybe --verbose will shed some light on the issue? Edit: Probably scratch that actually, this is probably related to [gulp-]imagemin not having read permissions for that file, but trying to read it anyway...
    – bsinky
    Mar 17, 2018 at 13:10
  • Could you post the relevant snippet from your gulpfile?
    – bsinky
    Mar 17, 2018 at 13:18
  • gulp.task('imageMin', () => gulp.src('src/img/*') .pipe(imagemin()) .pipe(gulp.dest('dist/img')) );
    – neca
    Mar 17, 2018 at 13:20

1 Answer 1

2

From your gulpfile, if thumbs.db is causing issues when an attempt is made to read it, it looks like you'll have to filter it out in your gulp.src step, try updating your gulpfile to exclude thumbs.db like so:

gulp.task('imageMin', () => gulp.src('src/img/*.!(db)')
    .pipe(imagemin())
    .pipe(gulp.dest('dist/img')));

The (probably cleaner) alternative would be to make sure Thumbs.db was never present in your img folder, but that might be easier said than done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.