pngquant icon indicating copy to clipboard operation
pngquant copied to clipboard

Preserving timestamps

Open jagdishadusumalli opened this issue 4 years ago • 7 comments

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?

jagdishadusumalli avatar Jul 18 '20 08:07 jagdishadusumalli

Hi @jagdishadusumalli .

Use stat and touch.

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

zvezdochiot avatar Jul 18 '20 08:07 zvezdochiot

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

kornelski avatar Jul 18 '20 19:07 kornelski

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

jagdishadusumalli avatar Jul 19 '20 05:07 jagdishadusumalli

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.

dverbru avatar Oct 23 '21 20:10 dverbru

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

prakash-partho avatar Nov 01 '21 09:11 prakash-partho

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

tobias992 avatar Jan 23 '23 19:01 tobias992

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

ReessKennedy avatar Dec 26 '23 18:12 ReessKennedy