简体   繁体   中英

Determine if image is already compressed/optimized?

Is there a Node.js library that can be used to determine if an image is already compressed/optimized?

One solution I thought of is that I could compress an image and then compare the before/after file size to make the determination. But I'm wondering if there is another, less intensive way to determine accomplish this.

I use gulp-imagemin to optimize the images (if they are already optimized it leaves them unchanged, otherwise it optimizes them) with a task in gulpfile.js like this:

gulp.task( 'images', function() {
    return gulp.src( 'path_img_folder/**/*' )
        .pipe( plugin.imagemin( {
            optimizationLevel: 7,
            progressive:       true,
            interlaced:        true,
            verbose:           true
        } ) )
        .pipe( gulp.dest( 'path_img_folder/' ) );
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM