How to use that free TINYPNG compressed picture?

  node.js, question

Does anyone use the plug-in gulp-tinypng-nokey?
I now have many folders in pic1 folder inside, and the number of their levels is uncertain. There is no problem when using the official API plug-in

var gulp = require('gulp');
 var tinypng = require('gulp-tinypng-compress');
 var tiny = require('gulp-tinypng-nokey');
 gulp.task('tp', function() {
 key: '***',
 sigFile: 'pic1/.tinypng-sigs',
 log: true

As above, if I use tinypng, he can normally cover uncompressed pictures. However, this requires a KEY and only 500 pictures per month, which is totally inadequate. ….

But if I use tiny’s method

gulp.task('tp', function() {

He will create a new directory under pic1 directory, and then all the pictures will be in this directory, inside. I need to find the corresponding pictures in each directory and overwrite them. After the file level is more than one, it will be more troublesome.

How can he maintain the original directory level? It is best to directly cover the original image with the newly generated image

Describe it again, for example, a picture A under pic1 is


The first method saved the path after modification, and the new picture is still here.
The second becomes

Pic1/ a name customized by plug-in /A.jpg

And all my pictures are in various directories, copying them one by one is especially troublesome.

Build a temporary folder as a transit directory, then move it over and overwrite it, then delete the temporary folder. In fact, the original image should not be covered. src and dist are best separated.