Download charts from Google Forms on Ubuntu Linux
If you run a survey using Google forms it will create a report with the results. For questions where people need to select one or more values you will see a pie-chart showing the results. You might want to download save these charts and then use it on a web site or in a presentation.
I found two options:
Screenshot
The first one is to create a screenshot of the chart. I just click on the Print Screen button of my keyboard. Some tool opens that allows me to select an area of the screen. Then when I press enter in creates a screenshot and saves it in ~/Pictures/Screenshots/ as a png image. This is the result from a recent survey I ran among the participants of my Open Source Development Course particpants. The image that was saved was 31,362 bytes.
Copy to clipboard and save from there
The other option is to use that copy button we see in the top-right corner of each chart. When we click on it the chart is copied to the clipboard. We can paste that directly into an email or a document (I tried LibreOffice document, but I assume it would also work in Microsoft word and in Google docs.)
I can also us the xclip command to save the content of the clipboard in a file as was described in the Save clipboard post.
xclip -selection clipboard -t text/html -o > downloaded.html
The result was a file of 167,501 bytes tha looked like this:
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <img src="data:image/png;base64,iVBORw0KGgoAAAA...mCC" alt="Forms response chart. Question title: How well do you know GitLab?. Number of responses: 11 responses." id="docs-internal-guid-cf3e7410-7fff-8a73-7757-c27f09525278">
It contains a png image in base64 encoding. I included the whole thing
I included it here, in this html file. If you click on view-source, you'll see the whole image in base64. It looks like one line from The Matrix.
Converting bas64 to png
I edited the downloaded html file and removed everything except the string representing the image:
iVBORw0KGgoAAAA...mCC
Then ran
base64 -d downloaded.html > out.png
The resulting file size was 125,402 bytes and this is the file:
I could then resize the image to make it smaller. Both at it is too high and wide and it is also a lot of bytes.
Published on 2023-01-10