asciidisco / grunt-imagine

Grunt tasks for optimizing & inlining images
MIT License
153 stars 21 forks source link

Globbing pattern '{…}' does not work in task paths #30

Closed marklindhout closed 10 years ago

marklindhout commented 11 years ago

I'm using grunt-imagine version 0.3.0 with grunt-cli v0.1.9 and grunt v0.4.1.

In my task I'm using the accolade {…} globbing pattern to look for different JPG files. The pattern looks like this: {jpg,jpe,jpeg}. No matter what I try, the pattern is not recognized, and the task responds with:

`Running "jpgmin" task

No matching files found!`

What can I do to fix this?

alpadev commented 11 years ago

Hey there!

Just tried it with this settings

jpgmin: {
  src: 'src/*.{jpg,jpe,jpeg}',
  dest: 'build',
  quality: 80
}

with: grunt-imagine v0.3.0 grunt-cli v0.1.10 grunt v0.4.1

Having test.jpg and test.jpeg in the src folder: Running "jpgmin" task

Compressed 2 files Uncompressed size: 590.39kb, Compressed size: 590.37kb, Savings: 0%

Seem to work fine here. May I ask for more details about that pattern that resulted in that output (you may mask it like src: ['abc/cd{e,f}/**/abc.{jpg,jpeg}'] but please add special characters/other glob patterns in case you have it in there)? Also I checked that task - yet it's internally just matching .jpg and .jpeg files. I'm about to add support for the mime module lookup to match files.

alpadev commented 11 years ago

Also sorry for the late reply. I had some high priority projects that literally diminished my spare time. I'll add a hotfix since it's just a minor change to have that jpe extension added. In case there is something wrong with the globs there will probably some delay till I may have a deeper look into this but there is a good chance to also fix https://github.com/asciidisco/grunt-imagine/issues/9 then.

marklindhout commented 11 years ago

Cool, thanks for the fix!

So if I understand correctly, internally the extensions are being overridden? This would mean I would not be able to minify a file called file.jpg.bak or a file without an extension?

alpadev commented 11 years ago

Yeah you are correct.

(Yet) there is a simple file-extension matching that actually doesn't recognize the file by type but by its extensions. Prior to the hotfix it been even worse because there were just .jpg and .jpeg hardcoded as matches (in case of the jpgmin task). (To explain it even more.. the glob pattern itself is just used for a file list - that may or may not contain other formats as well and then internally matched against some hardcoded patterns e.g. {.jpg,.jpeg} to drop files that can't be handled by that task). Now at least jpgmin accepts other extensions like .jpe but still - it needs the extensions to have a guess about the file. You may open another issue as enhancement to recognize files by it's headers so you may drop extensions or add .bak. For now that feature isn't implemented yet.

Greetings

alpadev commented 11 years ago

Guess you may be lucky (at least I am.. meeting got moved to tomorrow as such I have some time to implement a header lookup.. I guess it won't be to reliable at first but I'll be fixing bugs as they appear :)

alpadev commented 11 years ago

So there you go. This is now also supporting jpg.bak or extension less files as it's looking up the file by its header. :) But be aware I'd say it's currently in beta state or some sorta since I haven't tested it that much yet anyway feel free to try it.

marklindhout commented 11 years ago

Cool! I will check it out.

Thanks for your efforts :)