mcastorina / graph-cli

Flexible command line tool to create graphs from CSV data
785 stars 29 forks source link

support webp output #27

Open leafonsword opened 4 years ago

leafonsword commented 4 years ago

webp has better compression than png、jpg、gif, almost is the picture format king; hope support webp output~

mcastorina commented 4 years ago

graph-cli uses matplotlib.pyplot to save figures. When trying to save a webp image, I get this error:

ValueError: Format 'webp' is not supported (supported formats: eps, pdf, pgf, png, ps, raw, rgba, svg, svgz)

I will investigate further, but as a workaround you can use cwebp to convert png to webp:

graph-cli ➤ graph samples/sine.csv -o test.png                                                                                       git:master*
graph-cli ➤ cwebp -q 60 test.png -o test.webp                                                                                        git:master*
Saving file 'test.webp'
File:      test.png
Dimension: 1600 x 1000
Output:    27544 bytes Y-U-V-All-PSNR 45.37 49.90 49.72   46.42 dB
           (0.14 bpp)
block count:  intra4:        792  (12.57%)
              intra16:      5508  (87.43%)
              skipped:      4811  (76.37%)
bytes used:  header:            327  (1.2%)
             mode-partition:   5376  (19.5%)
 Residuals bytes  |segment 1|segment 2|segment 3|segment 4|  total
    macroblocks:  |       1%|       3%|       6%|      91%|    6300
      quantizer:  |      45 |      45 |      39 |      32 |
   filter level:  |      14 |      10 |       8 |       5 |
graph-cli ➤ ls -lh test.*                                                                                                            git:master*
-rw-r--r-- 1 miccah miccah 69K Feb  2 22:31 test.png
-rw-r--r-- 1 miccah miccah 27K Feb  2 22:31 test.webp
leafonsword commented 4 years ago

@mcastorina thx, since matplotlib doesn't support webp now, hope it could support later~