kornelski / pngquant

Lossy PNG compressor — pngquant command based on libimagequant library
https://pngquant.org
Other
5.25k stars 487 forks source link

Preserving timestamps #360

Open jagdishadusumalli opened 4 years ago

jagdishadusumalli commented 4 years ago

I have screenshots taken from 2016 and after and dont want to loose the timestamps of the files after optimization i know the filenames have the datetime info but i rely on file meta info.

I ran the command as many ways as below pngnq ~/Desktop/.png (creates new files) pngnq -f -e .png ~/Desktop/.png (replaces the old files)

All optimized files have Created/ Modified/ Added date set as Today after the processing.

I tried pngnq and it has a -p flag (preserve timestamps) and it works perfectly but the quality is a bit low

How can we keep the old timstamps preserved on files with pngquant?

zvezdochiot commented 4 years ago

Hi @jagdishadusumalli .

Use stat and touch.

PS: :warning: I'm not familiar with macOS.

kornelski commented 4 years ago

No, unfortunately there's no option to preserve timestamps.

jagdishadusumalli commented 4 years ago

Hi @kornelski Can we please add this into our "Feature Requests". Will be a worth addition to this great tool.

dverbru commented 3 years ago

Hello @kornelski

I second the request to have an option to preserve timestamps, like optipng's --preserve option and pngcrush's -oldtimestamp option. It is very useful when compressing old files! Would you consider it? Should I submit it again as a new issue? Thanks.

prakash-partho commented 3 years ago

Hello @kornelski I also request to have an option to preserve timestamps.

tobias992 commented 1 year ago

Hello Devs, any news with the --preserve option? To leave the old file attributes would be a very nice and helpful feature.

ReessKennedy commented 11 months ago

+1 but I also wrote some code that does this: https://www.reesskennedy.com/compression-enhancer/

It's PHP so super easy to run and then runs some shell commands to get the original creation and add it back after compression. I use it every day!

Could be translated to Python or anything. Perhaps some of your do something similar already and I know this is a request to add this directly into PNGQuant but just sharing a solution!!!!