Gulp-imagemin: how to preserve EXIF?

598 Views Asked by At

Is there a way to preserve metadata such as EXIF? I have been unable to find an option for this.

1

There are 1 best solutions below

1
On BEST ANSWER

The different imagemin plugins have different settings.

jpegoptim:

gulp.task('compressjpegoptim', () => {
  gulp
  .src('./images/*.jpg')
  .pipe(imagemin([imageminJpegoptim({
    stripAll: false,
    stripExif: false,
  })]))
  .pipe(gulp.dest('./dist'))
});

jpegtran

imagemin-jpegtran specifically ask jpegtran to remove the markers, with no options to keep them. If you modify this line in the source from 'none' to 'all' it will keep the Exif markers. This can be seen in jpegtran's documentation (search for Exif).

mozjpeg

This plugin seems to keep the Exif by default.