mahnunchik / gulp-responsive

gulp-responsive generates images at different sizes
https://npmjs.com/gulp-responsive
MIT License
502 stars 61 forks source link

Cannot convert JPG files: Error: Input buffer contains unsupported image format #66

Open eksperimental opened 7 years ago

eksperimental commented 7 years ago

While it converts PNG images without any problem, It cannot convert any jpg/jpeg image,

I get this error:

File foo.jpg: Input buffer contains unsupported image format

images are valid,

$ identify assets/images/foo.jpg 
assets/images/foo.jpg JPEG 1600x901 1600x901+0+0 8-bit sRGB 222KB 0.000u 0:00.000

this is the task

var plumber = require('gulp-plumber');
// Test subfolders
gulp.task('responsive-subfolders', function () {
  gulp.src(['./assets/images/**/*.{jpg,png}'])
  .pipe(plumber())
  .pipe(responsive(
    {
      '**/*.png': {
        width: 16,
        quality: 80,
      },
      '**/*.jpg': {
        width: 200,
        quality: 80,
      }
    }, {
      errorOnUnusedConfig: false,
      errorOnUnusedImage: false,
      errorOnEnlargement: false,
    }
  ))
  .pipe($.plumber())
  .pipe(gulp.dest('./tmp/'));
});

and here's the full error with gulp-plumber

[02:37:34] Plumber found unhandled error:
 Error in plugin 'gulp-responsive'
Message:
    File `foo.jpg`: Input buffer contains unsupported image format
quality: use jpeg({ quality: ... }), webp({ quality: ... }) and/or tiff({ quality: ... }) instead
progressive: use jpeg({ progressive: ... }) and/or png({ progressive: ... }) instead
withoutChromaSubsampling: use jpeg({ chromaSubsampling: "4:4:4" }) instead
compressionLevel: use png({ compressionLevel: ... }) instead

wondering if there is something wrong with my system

mahnunchik commented 7 years ago

Hi @eksperimental

It seems the file is corrupted or not supported by https://github.com/jcupitt/libvips

Could you share this file?

eksperimental commented 7 years ago

This @mahnunchik, thank you for your answer. In my previous example I have used the identify command from ImageMagick to determine the validity of the image, and it said it was fine (but it was was compressed by www.tinyjpg.com)

But it has happenedwith every JPG i have tried so far (even with images straight from a camera) I have used, this image https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg and the problem reamins.. any ideas?

mahnunchik commented 7 years ago

Hi @eksperimental

It seems this issue is not related to the images itself.

Try to do the following steps:

  1. Remove all gulp-plugins except gulp-responsive from the pipeline
  2. Upgrade or rebuild gulp-responsive (and sharp)
  3. Upgrade nodejs