Coder Social home page Coder Social logo

stnvh / gulp-tinypng-compress Goto Github PK

View Code? Open in Web Editor NEW

This project forked from creativeaura/gulp-tinypng

48.0 48.0 7.0 701 KB

TinyPNG API wrapper for compressing PNG & JPG images

JavaScript 100.00%
compress-images gulp gulp-plugin image-processing node tinypng tinypng-api

gulp-tinypng-compress's People

Contributors

creativeaura avatar stnvh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gulp-tinypng-compress's Issues

Write to .sig-file on watch?

This may be more of a 'request' than an issue. Having some trouble getting the package to write to the sig-file if it's watching for new images. So, on my default 'gulp' task images are compressed and the hash written to the sig-file. However, while Terminal is open and the default 'gulp' task is running I'm watching my 'img/raw/*' directory for new images and it compresses them just fine. Trouble is the hash isn't written to the sig-file when that happens. So the next time I run the default 'gulp' task it's going to compress again and will write to the sig-file.

My code thus far:

gulp.task('tinypng', function(){
    return gulp.src('img/raw/*.{png,jpg,jpeg}')
        // I've tried this at the end before notify, inside tinypng pipe, also as a separate watch task
        // but none of that writes to the sigfile on watch
        .pipe(watch('img/raw/*.{png,jpg,jpeg}'))
        .pipe(tinypng({
            key: 'api-key-dummy-text-here',
            sigFile: 'img/raw/.tinypng-sigs',
            log: true
        }))
        .pipe(gulp.dest('img'))
        .pipe(notify({
            message: "Images Compressed!"
        }));
});

Any thoughts? Thanks in advance!

upload concurrency

Hi there,

It could be great to allow multiple upload at the same time (like 4 by 4 uploads), because tinypng serv is a little slow while compressing.
grunt-tinypng is faster, because it allows connection concurrency. ;)

Thanks!

No images returned

I have installed the plugin according to instructions, but I'm not getting any actual images in the results, just copied folder structure.

var tinypngcomp = require('gulp-tinypng-compress');

gulp.task('tinypngcomp', function () {
    gulp.src('public/images/**/*.{png,jpg,jpeg}')
        .pipe(tinypngcomp({
            key: 'API_KEY',
            checkSigs: true,
            sigFile: 'public/images/.tinypng-sigs'
        }))
        .pipe(gulp.dest('public/tiny'));
});

The console only logs

[13:23:20] Starting 'tinypngcomp'...
[13:23:20] Finished 'tinypngcomp' after 5.06 ms

Not sure if related, but the original gulp-tinypng works fine with the same source and API_KEY.

Create .sig File when option is used

In my usage the plugin didn't create a .sig file and so always uploaded and compressed all the images in the folder. I could fix the problem by creating the .sig file manually.

would be great if the .sig file would be created automatically when the option is used.

sigFile does not handle deleted files

Hi there,

Thanks for your great tool and the improvements you're doing. ๐Ÿ˜ƒ

I have an issue with sigFile option: when you delete the dist folder, files are not reprocessed.
So if we are a team building our dist folder, my team won't process the files which are in it.

I'm not sure if I'm clear: I can provide more informations if you need.

Thanks again, and have a nice day!

checkSigs dont work

Hi !

your plugin look very promising !!!

But when i try to play with it, the checkSigs don't work.
No file has been create, and in each new gulp, the plugin compress all my assets...

It's a work in progress ?
Or i have something wrong ?

thanks !

Cannot find module 'gulp-tinypng-compress'

I get an error "Cannot find module 'gulp-tinypng-compress'" when trying to run gulp task. NodeJs version v0.12.2. All other npm modules run fine.
I've installed module like it says in docs:

npm install --save-dev gulp-tinypng-compress
var gulp = require('gulp');
var tinypng = require('gulp-tinypng-compress');

Full error stack:

module.js:338
    throw err;
          ^
Error: Cannot find module 'gulp-tinypng-compress'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/home/andrew/Desktop/test/gulpfile.js:5:15)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)

Am I the only one with such error?

wrong md5 hash in sigfile when same destination is being used

The sigfile md5 hash is not correct when the option sameDest = true is being used. The second run of the gulp task does not skip the same files but instead compresses them again because the md5 hash for the the old file contents is not the same as for the compressed one which was overriden by the option sameDest = true.

Support for same source/destination?

The cache functionality currently doesn't work if the source and destination are the same. The hash is calculated on the file on-disk not on the result from TinyPNG. This makes sense when the source and destination are different. However, it causes cache misses when source and destination are the same.

Digging through the source now to see where I might be able to implement an optional update based on the resulting file. However, my experience with gulp plugins is pretty limited.

uncaught exception

[15:59:03] Using gulpfile E:\Git\template-generator\gulpfile.js
[15:59:04] Starting 'tinypng'...
[15:59:07] gulp-tinypng-compress [compressing] โœ” desc-2.png (done)
[15:59:08] gulp-tinypng-compress [compressing] โœ” desc-1.png (done)
[15:59:09] gulp-tinypng-compress [compressing] โœ” desc-3.png (done)
[15:59:16] gulp-tinypng-compress [compressing] โœ” pic-1.jpg (done)
E:\Git\template-generator\node_modules\gulp-tinypng-compress\index.js:176
                            count: res.headers['compression-count'] || 0
                                      ^

TypeError: Cannot read property 'headers' of undefined
    at Object.<anonymous> (E:\Git\template-generator\node_modules\gulp-tinypng-compress\index.js:176:39)
    at self.callback (E:\Git\template-generator\node_modules\gulp-tinypng-compress\node_modules\request\request.js:368:22)
    at emitOne (events.js:77:13)
    at Request.emit (events.js:169:7)
    at Request.onRequestError (E:\Git\template-generator\node_modules\gulp-tinypng-compress\node_modules\request\request.js:1025:8)
    at emitOne (events.js:77:13)
    at ClientRequest.emit (events.js:169:7)
    at TLSSocket.socketErrorListener (_http_client.js:259:9)
    at emitOne (events.js:77:13)
    at TLSSocket.emit (events.js:169:7)

sigFile not created

Hi
I have following gulp task

gulp.task('tinypng', function () { gulp.src([ './uploads/**/*.{png,jpg,jpeg}' ]) .pipe(tinypng({ key: 'MY_TINY_PNG_KEY', sameDest: true, sigFile: './.sigFile', log: true })); });

but no .sigFile is created after image compression

[Feature request] - progress indicator

Hello,
first of all i love your fork of the original tinypng plugin.. its great..

Now to the point, as we are moving away from grunt and trying gulp, we discovered that there is no indicator of progress.. So for example, if you try to upload 3Mb image to the server you are just waiting and have no visible feedback..

The grunt version https://github.com/marrone/grunt-tinypng has options.showProgress which prints you the progress bar of upload and download inside terminal..

Honestly this is not needed, you some visual feedback to terminal of what is going on.

Thanks for your time.

No summary on error

Hi again,

After I reached my monthly limit, your plugin stops, but... There's no summary.
Why ? ๐Ÿ˜ข

option.sigFile not work

Thanks for your work.
But here's a problem for me, my gulpfile is like this:

gulp.task('mobile-web-img', function () {
  return gulp.src('web/bundles/custommobileweb/img/**/*.{png, jpg, jpeg}')
    .pipe(tinypng({
      key: 'API_KEY',
      sigFile: 'web/bundles/custommobileweb/img/.tinypng-sigs',
      log: true,
      summarize: true
    })).on('error', function (err) {
      console.error(err.message);
    })
    .pipe(gulp.dest('web/bundles/custommobileweb/dist/img'))
});

but there's no .tinypng-sigs is created.
I have 200+ images in this folder, the plugin upload all images every time I run the task.
And I tried set sigFile: './.tinypng-sigs' and created .tinypng-sigs' file myself, but it still not work.
What can I do? I've made something wrong?

And one more question, when it there's one image(e.g. name: a.png) on error, will the images before this one that had compressed write into the .tinypng-sigs file?

tinypng-compress for webpack

Hi !

We LOVE your plugin for gulp.
We're thinking about switching for Webpack. But we will miss your plugin.

It would be very great to have your plugin on Webpack :)

Thanks for all !

NPM audit finds vulnerabilities

  • gulp-tinypng-compress > request > hawk > boom > hoek
  • gulp-tinypng-compress > request > hawk > cryptiles > boom > hoek
  • gulp-tinypng-compress > request > hawk > hoek
  • gulp-tinypng-compress > request > hawk > sntp > hoek
  • gulp-tinypng-compress > minimatch
  • gulp-tinypng-compress > request > tunnel-agent
  • gulp-tinypng-compress > request
  • gulp-tinypng-compress > request > hawk

Any reason why request and minimatch cant be upgraded to the latest version?

tinypng-sigs

How do I use this option?

Do I setup the path like this? as a text file with .tinypng-sigs extension?

.pipe(tinypng({ key: '99p7KPH2gMG00lzdrRHkRm0Fl2G135z5', sigFile: 'assets/img/.tinypng-sigs', log: true }))

Use file path for check signature

Hi,
thank you for this plugin, it's really useful.
When I use sameDest option, image signatures are calculated using only file names.

So when I have two image with the same name (but in different path), the second image's signature overwrites the first image's signature, and the next time both images are processed again and so on.

Is it possible to use file path to identify signatures?

Cannot set property 'conf' of undefined

Every time I try to use the plugin, I get the fallowing error:

'tinypng' errored after 5.49 ms
TypeError: Cannot set property 'conf' of undefined

gulp.task( 'tinypng', function() {
    gulp.src( 'project/htdocs/img/**/*.{png,jpg,jpeg}')
        .pipe( tinypng({
            key: 'XXXXXXXXXXXX',
            checkSigs: true,
            sigFile: 'project/htdocs/img/.tinypng-sigs',
            log: true
        }) )
        .pipe( gulp.dest( 'project/htdocs/img' ) );
});

Any idea why?
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.