stnvh / gulp-tinypng-compress Goto Github PK
View Code? Open in Web Editor NEWThis project forked from creativeaura/gulp-tinypng
TinyPNG API wrapper for compressing PNG & JPG images
This project forked from creativeaura/gulp-tinypng
TinyPNG API wrapper for compressing PNG & JPG images
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!
hope add option to set compress level
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!
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.
TinyPng offers an api for preserving the metadata like copyright, creation and location. It would be nice if the plugin could offer this kind of feature either.
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.
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!
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 !
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?
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.
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.
[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)
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
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.
Hi again,
After I reached my monthly limit, your plugin stops, but... There's no summary.
Why ? ๐ข
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?
[email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
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 !
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?
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 }))
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?
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.