derhuerst/gulp-scale-images

Gulp v5 needs encoding: false

Open

#35 opened on Jun 11, 2024

View on GitHub
 (1 comment) (1 reaction) (0 assignees)JavaScript (5 forks)github user discovery
docshelp wanted

Repository metrics

Stars
 (13 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Updating to gulp v5 all my worflows with gulp-scale-images were broken: "Error: Input buffer contains unsupported image format"

There was only one result in google for this error, but this pointed towards a problem with svgs and sharp.

Gulp v5 changed the default encoding of all of their streams to UTF-8. gulp-scale-images does not seem aware of this and expects a binary stream?

What you have to do is set encoding to false on your streams.

return gulp
  // Load file
  .src(data.source, {encoding: false})
  
  // We want to have multiple sizes per source image
  .pipe(flatMap.default(variantsPerFile))
  
  // Scale the images
  .pipe(scaleImages(computeFileName))
  
  // Write result file
  .pipe(gulp.dest(application.destinationPath + '/' + key));

With this change my workflow are once again working correctly.

Can you either add this to the README or somehow fix this in code?

Contributor guide