Closed JamieMason closed 5 years ago
What sort of schema where you thinking of?
{
"stats": {
"files": [{
"name": "jimmy.png",
"prev": "217kB",
"now": "56.6kB",
"saving": "160kB",
"perc": "73.91%"
},
{
"name": "jimmy2.png",
"prev": "233kB",
"now": "65.9kB",
"saving": "167kB",
"perc": "71.74%"
}
],
"total": {
"prev": "2.01MB",
"now": "1.1MB",
"saving": "908kB",
"perc": "45.21%"
}
}
}
or
{
"stats": [{
"name": "png8_bril.png",
"was": "60.9kB",
"now": "54.9kB",
"saving": "5.92kB",
"perc": "9.73%"
},
{
"name": "png8_grote-ogen.png",
"was": "68.2kB",
"now": "62kB",
"saving": "6.23kB",
"perc": "9.14%"
},
{
"name": "TOTAL",
"was": "539kB",
"now": "450kB",
"saving": "89kB",
"perc": "16.51%"
}
]
}
I've never done any TypeScript before, so I thought I'd learn a bit, so started on this: https://github.com/jamesstout/ImageOptim-CLI/tree/json-output
Sorry for the wait @jamesstout, there is a shape in use at https://github.com/JamieMason/ImageOptim-CLI/blob/master/src/get-stats.ts#L5-L23 which I was just thinking of exposing a CLI option for writing to disk. There'd be some adjustments needed for adding in the quality loss info but I think that would be better picked up as part of https://github.com/JamieMason/ImageOptim-CLI/issues/162.
That said, open to any ideas on any changes that might improve things.
Cheers J
Closing as YAGNI.
Add
--json
option to output stats in serialised JSON format.