grunt-imagine icon indicating copy to clipboard operation
grunt-imagine copied to clipboard

jpgmin with quality does not overwrite files if dest matches src

Open ilovett opened this issue 11 years ago • 3 comments

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...

ilovett avatar May 07 '14 04:05 ilovett

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?!

asciidisco avatar May 07 '14 11:05 asciidisco

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

LaurentGoderre avatar May 07 '14 13:05 LaurentGoderre

I like the overwrite: true flag idea

ilovett avatar May 07 '14 15:05 ilovett