heldr / grunt-smushit Goto Github PK
View Code? Open in Web Editor NEWGrunt task to optimize images using reSmush.it
License: MIT License
Grunt task to optimize images using reSmush.it
License: MIT License
Hi,
Im new to node stuff but still im trying to use this grunt plugin.
When i run grunt it seams to run my original images folder, returning lines like this:
[grunt-smushit] New optimized file: images/dist/temp/themeGallery-02.jpg
[smushit] smushit completed: total 1, saving 0
When i check the destination folder grunt as recreated the folder structure but didn't create any image.
Am i missing something?
Regards.
Create test cases and support this task config:
grunt.initConfig({
smushit: {
// a single directory
group1: {
src: 'tests/img'
},
// filter by filetype
group2: {
src: ['tests/img/**/*.png','tests/img/**/*.jpg']
},
//replace recursive
group3: {
src: ['tests/img/logo.png','tests/img/tellme.jpg']
}
}
});
Create the new plugin files structure on top of grunt-init-gruntplugin.
Hi,
I'm having an issue when I try to smush a bunch of png's using this:
destination:{
src:'path/to/unsmushed/images',
dest:'different/path/to/smushed/images'
}
Grunt-smushit, successfully smushes a few images (1-5, kinda randomly). But sometimes some files are corrupted.
Increasing the delay parameter of the setTimeout
in tasks/smushit.js (line 38)
seems to fix this issue, but adds unwanted delay to the end of the smushit task.
Thank you for your help and Grunt plugin !
Create test cases and support this config:
grunt.initConfig({
smushit: {
// catch all files from a single folder
group1: {
src: 'tests/img',
dest: 'tests/opt_img'
},
// filter by filetype
group2: {
src: ['tests/img/**/*.png','tests/img/**/*.jpg'],
dest: 'tests/img/min'
},
// set each file
group3:{
src: ['tests/img/logo.png','tests/img/whatever.png'],
dest: 'tests/img/min'
}
}
});
When using src
patterns such as ./img
instead of img
, an extraneous g/
directory is created in the dest
dir. I don't see why one src
pattern is to be preferred over the other; both are valid paths and both should work.
This is essentially a duplicate of #28 that @dmcass opened. There is substance here, however his fix was incorrect. Instead of hardcoding a + 1
(cc764d9), it seems better to always path.normalize
filepath
in the same way that fileDir
is normalized.
grunt/grunt-smushit (master)
$ npm install grunt-smushit
npm WARN install Refusing to install grunt-smushit as a dependency of itself
And:
$ grunt
Running "jshint:files" (jshint) task
Linting tasks/smushit.js...ERROR
[L36:C1] Trailing whitespace.
Why that?Thanks.
An option with one/many input files (possibly a folder), with an output folder. This is to keep the source images unsmushed while working with them.
I have a gruntfile that does multiple tasks. I would like to use smushit in the middle somewhere, but everything I do it doesn't execute any tasks after.
end of my grunt default task
...
, 'replace:jspIncludesPass3'
, 'smushit'
, 'shell:createTemplates'
...
here is a screenshot. couldn't get it to embed
https://www.flickr.com/photos/97129686@N03/8980565404/
That has a problem in smushit.js:
$ grunt build
Running "jshint:files" (jshint) task
Linting tasks/smushit.js...ERROR
[L36:C1] Trailing whitespace.
The target path should be the dest and not the concatenation for the cwd + dest. See Line 36.
So, I've started testing this, but realised that I'd need to name each file individually, rather than being able to just recursively moving/smushing an entire folder.
Is this something you're working on, or not interested in? (If it's not something you're interested in, I'm planning on working on it, since I need it =)
I'd like to be able to configure whether to display the full file list while the task is running. In my case, we have dozens of files that are being compressed, and the deluge of output is not always useful for us. I'd like to see something like this (it doesn't have to be named verbose, but that seemed like a good enough name for the example):
...
smushit: {
options: {
verbose: false
},
mygroup: {
src: ['tests/img/**/*.png','tests/img/**/*.jpg'],
dest: 'tests/img/min'
}
}
...
I'm posting this issue to let you know that we will be publishing Grunt 0.4 on Monday, February 18th.
If your plugin is not already Grunt 0.4 compatible, would you please consider updating it? For an overview of what's changed, please see our migration guide.
If you'd like to develop against the final version of Grunt before Monday, please specify "grunt": "0.4.0rc8"
as a devDependency in your project. After Monday's release, you'll be able to use "grunt": "~0.4.0"
to actually publish your plugin. If you depend on any plugins from the grunt-contrib series, please see our list of release candidates for compatible versions. All of these will be updated to final status when Grunt 0.4 is published.
Also, in an effort to reduce duplication of effort and fragmentation in the developer community, could you review the grunt-contrib series of plugins to see if any of your functionality overlaps significantly with them? Grunt-contrib is community maintained with 40+ contributors—we'd love to discuss any additions you'd like to make.
Finally, we're working on a new task format that doesn't depend on Grunt: it's called node-task. Once this is complete, there will be one more conversion, and then we'll never ask you to upgrade your plugins to support our changes again. Until that happens, thanks for bearing with us!
If you have any questions about how to proceed, please respond here, or join us in #grunt on irc.freenode.net.
Thanks, we really appreciate your work!
When I try to utilize the smushit
task with grunt 0.4.0a, it fails:
Running "smushit:destination" (smushit) task
Warning: Cannot call method 'kindOf' of undefined Use --force to continue.Aborted due to warnings.
Here's my [simplified] "Gruntfile.js" configuration:
module.exports = function(grunt) {
grunt.initConfig({
clean: {
all: ['out/']
},
smushit: {
destination: {
src: ['in/*.png', 'in/*.jpg'],
dest: 'out/'
}
}
});
// Load supplemental libraries
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-smushit');
// Default task
grunt.registerTask('default', ['clean', 'smushit']);
};
The results between the two options are quite large when using the web version.
As reported on #16 , a grunt-smushit user must have the option to set your favorite service. The v1 release must cover it using the grunt options object.
grunt.initConfig({
smushit: {
options: {
service: 'http://myimgopt.com/exec'
},
mygroup: {
src: ['tests/img/**/*.png','tests/img/**/*.jpg'],
dest: 'tests/img/min'
}
}
});
marie@venus:~$ npm install -g grunt-smushit
npm http GET https://registry.npmjs.org/grunt-smushit
npm http 404 https://registry.npmjs.org/grunt-smushit
npm ERR! 404 'grunt-smushit' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
Which is a real shame, this one looks awesome! =)
Yahoo stopped maintaining smush.it web service
http://www.phpied.com/smush-it-is-dead-long-live-smushing/
So, this project will be deprecated. 😢
it's really not a error and other tasks can't continue
I like your task!
Is it possible to recreate the folder structure in the target folder when using:
destination:{
src:'tests/img',
dest:'tests/img/min'
},
Thanks in advance!
Allow array with directories as source. Reported at this comment: #5 (comment)
I'm probably doing something wrong, but also this may be a bug.
Here's my config:
smushit: {
group1: {
cwd: '',
expand: true,
src: ['images/**/*.png'],
dest: 'dist/images',
ext: '.png'
},
},
The output is:
Running "smushit:group1" (smushit) task
[smushit] start smash dist/images/icons/.svn/prop-base/apple-touch-icon-114x114-precomposed.png.svn-base
[smushit] start smash dist/images/icons/.svn/prop-base/apple-touch-icon-144x144-precomposed.png.svn-base
[smushit] start smash dist/images/icons/.svn/prop-base/apple-touch-icon-72x72-precomposed.png.svn-base
[smushit] start smash dist/images/icons/.svn/prop-base/apple-touch-icon-precomposed.png.svn-base
[smushit] start smash dist/images/icons/.svn/text-base/apple-touch-icon-114x114-precomposed.png.svn-base
[smushit] start smash dist/images/icons/.svn/text-base/apple-touch-icon-144x144-precomposed.png.svn-base
[smushit] start smash dist/images/icons/.svn/text-base/apple-touch-icon-72x72-precomposed.png.svn-base
[smushit] start smash dist/images/icons/.svn/text-base/apple-touch-icon-precomposed.png.svn-base
[smushit] start smash dist/images/icons/apple-touch-icon-114x114-precomposed.png
[smushit] start smash dist/images/icons/apple-touch-icon-144x144-precomposed.png
[smushit] start smash dist/images/icons/apple-touch-icon-72x72-precomposed.png
[smushit] start smash dist/images/icons/apple-touch-icon-precomposed.png
[smushit] item: dist/images/icons/.svn/prop-base/apple-touch-icon-144x144-precomposed.png.svn-base error: Cannot determine the type, is this an image?
[smushit] item: dist/images/icons/.svn/prop-base/apple-touch-icon-precomposed.png.svn-base error: Cannot determine the type, is this an image?
[smushit] item: dist/images/icons/.svn/prop-base/apple-touch-icon-72x72-precomposed.png.svn-base error: Cannot determine the type, is this an image?
[smushit] item: dist/images/icons/.svn/prop-base/apple-touch-icon-114x114-precomposed.png.svn-base error: Cannot determine the type, is this an image?
[smushit] item: dist/images/icons/.svn/text-base/apple-touch-icon-114x114-precomposed.png.svn-base error: No savings
[smushit] item: dist/images/icons/.svn/text-base/apple-touch-icon-72x72-precomposed.png.svn-base error: No savings
[smushit] item: dist/images/icons/.svn/text-base/apple-touch-icon-144x144-precomposed.png.svn-base error: No savings
[smushit] item: dist/images/icons/.svn/text-base/apple-touch-icon-precomposed.png.svn-base error: No savings
[smushit] item: dist/images/icons/apple-touch-icon-114x114-precomposed.png saving: 49.17%
[smushit] item: dist/images/icons/apple-touch-icon-precomposed.png saving: 61.62%
[smushit] item: dist/images/icons/apple-touch-icon-72x72-precomposed.png saving: 61.82%
[smushit] item: dist/images/icons/apple-touch-icon-144x144-precomposed.png saving: 60.78%
[smushit] smushit completed: total 12, saving 4
If I use src: ['images/**/*.png', '!images/**.svn*]
or something similar, it tells me that the !images
path is not found.
Any thoughts?
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.