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

crashes if image is too small

Open rubycut opened this issue 8 years ago • 14 comments

events.js:160
      throw er; // Unhandled 'error' event
      ^
Error: File `X_logo.jpg`: Image enlargement is detected
  real width: 153px, required width: 200px

(sharp:3559): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed

(sharp:3559): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed

(sharp:3559): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed

(sharp:3559): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed

(sharp:3559): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed

rubycut avatar Jan 26 '17 19:01 rubycut

Hi @rubycut

Options: withoutEnlargement and errorOnEnlargement may help you.

mahnunchik avatar Jan 27 '17 08:01 mahnunchik

@mahnunchik , those options don't help at all, output is the same.

rubycut avatar Feb 04 '17 15:02 rubycut

+1. Even if I set withoutEnlargement to true and errorOnEnlargment to false, I still get the same error when resizing images.

If I comment out this line then it works as expected (a warning is logged and the raw image is copied without resizing). Is it possible the errorOnEnlargment config isn't being plumbed through to here correctly?

jqln-0 avatar Feb 08 '17 10:02 jqln-0

+1 - I have the exact same issue.

What's strange is that it doesn't happen with all images.

mattstratton avatar Feb 21 '17 12:02 mattstratton

Same issue here, on a 2000x350 image.

andrewplummer avatar Feb 22 '17 05:02 andrewplummer

Same issue... any update?

tehtrav avatar Mar 09 '17 20:03 tehtrav

(( same issue(

7iomka avatar May 11 '17 17:05 7iomka

Hi @7iomka @tehtrav @andrewplummer @mattstratton @jqln-0

Are you using the global option errorOnEnlargement?

gulp.task('default', function () {
  return gulp.src('src/*.png')
    .pipe(responsive(config, {
      errorOnEnlargement: false
    }))
    .pipe(gulp.dest('dist'));
});

mahnunchik avatar May 13 '17 05:05 mahnunchik

Yes! That it works! My config:

withoutEnlargement: true,
skipOnEnlargement: false, // that option copy original file with/without renaming
errorOnEnlargement: false

7iomka avatar May 13 '17 15:05 7iomka

Hi @7iomka

It is exactly what corresponds to your original question and how I use gulp-responsive myself 😉

mahnunchik avatar May 14 '17 05:05 mahnunchik

There seems to be something more going on with this. Every time it hits an image that requires enlargement it dies, unless I set 'withoutEnlargement' to false. Gulp task is:

function imgResponsive() {
  return gulp.src('src/img_tmp/**/*.{jpg,png}')
    .pipe(plugins.responsive(config.responsiveOptions, config.responsiveGlobals))
    .pipe(gulp.dest('src/img_responsive/'));
}

config.js contains:

  responsiveGlobals: {
    quality: 86,
    progressive: true,
    withMetadata: false,
    withoutEnlargement: true,
    errorOnEnglargement: false,
    skipOnEnlargement: false,
    errorOnUnusedConfig: false
  },

Used to work in the distant past, tried rolling back versions of gulp-responsive and sharp but still get the same error.

Example error:

21:34:17] Error in plugin 'gulp-responsive'
Message:
    File `Yarbus_EMs_Sonnet.jpg`: Image enlargement is detected
  real width: 921px, required width: 1024px
Details:
    domainEmitter: [object Object]
    domain: [object Object]
    domainThrown: false
[21:34:17] 'reprocess:responsive' errored after 8.13 s

(sharp:74647): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed

(sharp:74647): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed

(sharp:74647): GLib-CRITICAL **: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed

(sharp:74647): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
[1]    74647 segmentation fault  gulp reprocess:responsive

By playing with the config width parameters I can trigger the error with different images, depending on size. Workaround for now is allow enlargement (ick) or only generate sizes <= the smallest images width. On OSX 10.11.6 el capitan sharp 0.18.4 gulp-responsive 2.8.0 vips 8.5.9 installed via macports on macports installed python 3.4 (didn't seem to work on 2.7).

adrinux avatar Dec 19 '17 21:12 adrinux

Hi @adrinux

Could you please try your config with build in shrap: http://sharp.dimens.io/en/stable/install/#mac-os

@lovell do you have any idea about the error above?

mahnunchik avatar Dec 20 '17 05:12 mahnunchik

The GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed message usually means there are other images still being processed by the libuv-managed threadpool when process.exit() is manually called. Node does not wait for these threads to "join" before exiting and this can cause a segfault on shutdown as the event loop is not empty.

To avoid this, gulp-responsive could wait for sharp.counters().queue to reach zero before throwing errors, if any.

lovell avatar Dec 20 '17 09:12 lovell

@mahnunchik I removed macports vips, also removed the separate copy of sharp I'd added to package.json, then removed my project's node_modules and ran npm install again. End result was '[1] 64556 illegal hardware instruction gulp reprocess:responsive' - and that's with config that was working (didn't trigger image enlargement warning).

Problem may not be in gulp-responsive I suppose

Edit to add: Reinstalled vips with macports and reinstalled gulp-responsive, now back to a working setup as long as I avoid triggering the image enlargement warning.

adrinux avatar Dec 20 '17 12:12 adrinux