asciidisco / grunt-imagine

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

jpgmin with quality does not overwrite files if dest matches src #55

Open ilovett opened 10 years ago

ilovett commented 10 years ago

If the src matches the dest:

jpgmin : {
    quality : 30,
    src : ['tmp/**/*.jpg'],
    dest : 'tmp',
}

Then the quality doesn't seem to make a difference:

Running "jpgmin" task
>> Compressed 1 files
>> Uncompressed size: 2577.7kb, Compressed size: 2461.01kb, Savings: 4.53%

However if I change the dest directory:

jpgmin : {
    quality : 30,
    src : ['tmp/**/*.jpg'],
    dest : 'other',
}

Then here is the output:

Running "jpgmin" task
>> Compressed 1 files
>> Uncompressed size: 2577.7kb, Compressed size: 85.65kb, Savings: 96.68%

This compresses, however the file is written to: other/img/filename.jpg ... I would like to be able to overwrite the file as this is a step in a chain of modifications to the image...

asciidisco commented 10 years ago

The output is a bit misleading, I originally designed the task to not overwrite source files (to avoid accidentally losing image information like EXIF data).

If you really wan't to override your source files, run imagine first & "manually" apply a step that will move/copy the files afterwards.

@alpadev @LaurentGoderre: Should we add a warning/info message if imagine tries to override the source files giving the user a hint?!

LaurentGoderre commented 10 years ago

Maybe there should be a flag to allow overwriting but by default it could give a warning when overwriting a file?

ilovett commented 10 years ago

I like the overwrite: true flag idea