question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Skipping files which give "Premature end of JPEG file"

See original GitHub issue

When using gulp-imagemin to minimize thousands of files (16,000).

In this directory there are about a 1000 damaged files that give “Premature end of JPEG file” error.

Is there a way to skip optimization for these files without crashing the task?

Does anyone have a solution ?

LOG:

events.js:160
      throw er; // Unhandled 'error' event
      ^
Error: Premature end of JPEG file

    at Promise.all.then.arr (D:\php_workspace\photo_shrink\2f076e49f92998893f1b4004ebf9de6e\node_modules\execa\index.js:202:11)


CODE: gulp.task(‘default’, function(){ return gulp.src([from + ‘//*.png’,from + '//.jpg’,from + '/**/.jpeg’,from + ‘/**/*.gif’]) .pipe(filelog()) .pipe(imagemin()) .pipe(gulp.dest(to)); });

gulp.start(‘default’);

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
lusarealcommented, Aug 22, 2019

I might be missing something, but where is events.js located? I can’t seem to find it anywhere

You can do this in /node-modules/gulp-imagemin/index.js

catch (error) {
				//callback(new PluginError(PLUGIN_NAME, error, {fileName: file.path}));
				console.log(error);
				console.log(file.path);				
			}
0reactions
Jsonzhangcommented, Oct 14, 2018
 gulp.src('static/*.jpg')
.pipe(imagemin().on('error', function(e){}))
.pipe(gulp.dest('./dist'))

Hope it helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Premature end of JPEG file - Stack Overflow
Interesting and strange part is that i am getting this error only when i upload any camera taken images, like from mobile, other...
Read more >
Premature end of JPEG file - Agisoft Metashape
I'm getting the error "premature end of jpeg file" while merging five chunks with an average of about 1000 images in them.
Read more >
Premature end of JPEG file - Processing Forum
I am trying to load JPEG files into processing while they are constantly being written onto my machine form an external camera.
Read more >
[GM-help] premature end of JPEG/Unsupported marker type
Hello. I ran into a couple weird errors today. I have two jpeg files which were created in different ways but are both...
Read more >
Corrupted DICOM JPEG file - Google Groups
second entry dcmdump: error: I/O suspension or premature end of stream: reading file: C:\temp\GENESIS_SIGNA-JPEG-CorruptFrag.dcm. Ross's profile photo ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found