Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on smaller images #148

Open
djmtype opened this issue Jul 25, 2020 · 4 comments
Open

Error on smaller images #148

djmtype opened this issue Jul 25, 2020 · 4 comments

Comments

@djmtype
Copy link

djmtype commented Jul 25, 2020

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
Copy link
Author

djmtype commented Jul 25, 2020

BTW, I've tried variations of these settings:

withoutEnlargement: true,
skipOnEnlargement: true,

@germolinal
Copy link

Same here.

@menteora
Copy link

menteora commented Mar 20, 2021

withoutEnlargement: false,

works for me.

@cssagogo
Copy link

cssagogo commented Aug 6, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants