exuanbo/gulp-jimp-wrapper

Images are not processed

expwez opened this issue · 1 comments

After the latest update (1.1.0), I keep retrieving the same exception while trying to use the package. The exception is:

TypeError: Cannot read property 'slice' of undefined
    at getMIMEType (/srv/app/node_modules/gulp-jimp-wrapper/dist/index.js:25:51)
    at Transform.through__default.default.obj [as _transform] (/srv/app/node_modules/gulp-jimp-wrapper/dist/index.js:62:24)
    at Transform._read (/srv/app/node_modules/gulp-jimp-wrapper/node_modules/readable-stream/lib/_stream_transform.js:177:10)
    at Transform._write (/srv/app/node_modules/gulp-jimp-wrapper/node_modules/readable-stream/lib/_stream_transform.js:164:83)
    at doWrite (/srv/app/node_modules/gulp-jimp-wrapper/node_modules/readable-stream/lib/_stream_writable.js:409:139)
    at writeOrBuffer (/srv/app/node_modules/gulp-jimp-wrapper/node_modules/readable-stream/lib/_stream_writable.js:398:5)
    at Transform.Writable.write (/srv/app/node_modules/gulp-jimp-wrapper/node_modules/readable-stream/lib/_stream_writable.js:307:11)
    at write (/srv/app/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:623:24)
    at flow (/srv/app/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:632:7)
    at DestroyableTransform.pipeOnReadable (/srv/app/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:664:5)

And I am using the package like this:

return gulp.src(imagesConfig.source)
                .pipe(function (image) {
                    image.resize(size.width, size.height);
                    image.crop(crop.x, crop.y, crop.width, crop.height);

                    return image;
                })
                .pipe(gulp.dest(imagesConfig.destination));

Is there any solution for me in this situation?

slice() is called when getting the MIME type of the image.

const getMIMEType = img => MIME_TYPES[img.extname.slice(1).toLowerCase()]

It seems the property extname is somehow undefined in the Vinyl instance.

Can you provide some examples of your imagesConfig.source?