gulp-responsive icon indicating copy to clipboard operation
gulp-responsive copied to clipboard

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

Open eksperimental opened this issue 8 years ago • 3 comments

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

eksperimental avatar Dec 26 '16 19:12 eksperimental

Hi @eksperimental

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

Could you share this file?

mahnunchik avatar Dec 27 '16 07:12 mahnunchik

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?

eksperimental avatar Dec 27 '16 12:12 eksperimental

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

mahnunchik avatar Jan 04 '17 03:01 mahnunchik