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

Error on smaller images

Open djmtype opened this issue 5 years ago • 4 comments

If one of my images happens to be smaller than the smallest size (576px) setting, I get an error and the gulp images task stops performing.

[11:27:13] 'images' errored after 641 ms
[11:27:13] Error in plugin "gulp-responsive"
Error
    at DestroyableTransform.through2Handler [as _transform] (/Users/me/Sites/_image-transforms/node_modules/gulp-responsive/lib/index.js:98:14)

My gulpfile:

var gulp = require('gulp')
var responsive = require('gulp-responsive')
gulp.task('images', function() {
	return gulp
		.src('src/img/*.{jpg,png}')
		.pipe(
			responsive({
				'*.jpg': [{
						width: 576,
						rename: {
							suffix: '-sm'
						}
					},
					{
						width: 768,
						rename: {
							suffix: '-md'
						}
					},
					{
						width: 1024,
						rename: {
							suffix: '-lg'
						}
					},
					{
						width: 1200,
						rename: {
							suffix: '-xl'
						}
					},
					{
						rename: {
							suffix: ''
						}
					},
				],
			}, {
				quality: 70,
				progressive: true,
				compressionLevel: 5,
				withMetadata: false,
				withoutEnlargement: true,
				skipOnEnlargement: false, 
			})
		)
		.pipe(gulp.dest('dist'))
})

djmtype avatar Jul 25 '20 15:07 djmtype

BTW, I've tried variations of these settings:

withoutEnlargement: true,
skipOnEnlargement: true,

djmtype avatar Jul 25 '20 15:07 djmtype

Same here.

germolinal avatar Feb 02 '21 22:02 germolinal

withoutEnlargement: false,

works for me.

menteora avatar Mar 20 '21 14:03 menteora

I'm seeing similar error when any size is provided and a matching image is smaller...

         .pipe(
            responsive({
                '**/*.png': [
                { width: 480, rename: { suffix: '-480px', extname: '.jpg' }, withoutEnlargement: true },
                { width: 640, rename: { suffix: '-640px', extname: '.jpg' }, withoutEnlargement: true },
                { width: 997, rename: { suffix: '-997px', extname: '.jpg' }, withoutEnlargement: true }, // Succeeds on 997px image.
                { width: 998, rename: { suffix: '-998px', extname: '.jpg' }, withoutEnlargement: true }, // Fails on 997px image.    
                ]
            },
            {
                // Global configuration for all images
                // The output quality for JPEG, WebP and TIFF output formats
                quality: 70,
                // Use progressive (interlace) scan for JPEG and PNG output
                progressive: true,
                // Zlib compression level of PNG output format
                compressionLevel: 6,
                // Strip all metadata
                withMetadata: false
            })
        )

And the console output when it fails...

    [23:41:55] 'imgBuild' errored after 594 ms
    [23:41:55] Error in plugin "gulp-responsive"
    Error at DestroyableTransform.through2Handler [as _transform] (/node_modules/gulp-responsive/lib/index.js:98:14)
    
    (sharp:3898): GLib-CRITICAL **: 23:41:55.402: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    
    (sharp:3898): GLib-CRITICAL **: 23:41:55.402: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    
    (sharp:3898): GLib-CRITICAL **: 23:41:55.403: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    
    (sharp:3898): GLib-CRITICAL **: 23:41:55.403: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed
    
    (sharp:3898): GLib-CRITICAL **: 23:41:55.403: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    Segmentation fault (core dumped)
    npm ERR! code ELIFECYCLE
    npm ERR! errno 139
    npm ERR! [email protected] gulp: `gulp "imgBuild"`
    npm ERR! Exit status 139
    npm ERR! 
    npm ERR! Failed at the [email protected] gulp script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /home/vagrant/.npm/_logs/2021-08-06T23_41_55_603Z-debug.log

cssagogo avatar Aug 06 '21 23:08 cssagogo