'Turn array of x,y coordinates in to a line (jpg) - Python [closed]

I am receiving a "signature" that has been drawn on a basic capture device, through an API call.

The response data from the device has a json object in it with the "signature", which I preparse in javascript and in turn pass to a python service which needs to store the captured signature, as a base64 encoded image (jpg preferably).

I could do the conversion in javascript (as per an answer given), if it must be there, but would prefer to do it in the python layer.

Here is an example of the data I am getting:

{ "data": [ { "x": "2B", "y": "58" }, { "x": "2D", "y": "5B" }, { "x": "2E", "y": "5E" }, { "x": "30", "y": "61" }, { "x": "30", "y": "63" }, { "x": "32", "y": "65" }, { "x": "33", "y": "67" }, { "x": "35", "y": "69" }, { "x": "36", "y": "6C" }, { "x": "38", "y": "6E" }, { "x": "3A", "y": "71" }, { "x": "3C", "y": "73" }, { "x": "3D", "y": "75" }, { "x": "41", "y": "79" }, { "x": "42", "y": "7B" }, { "x": "46", "y": "7F" }, { "x": "47", "y": "81" }, { "x": "49", "y": "83" }, { "x": "4D", "y": "89" }, { "x": "4F", "y": "8B" }, { "x": "52", "y": "8D" }, { "x": "54", "y": "8F" }, { "x": "57", "y": "90" }, { "x": "59", "y": "93" }, { "x": "5C", "y": "95" }, { "x": "61", "y": "9A" }, { "x": "63", "y": "9D" }, { "x": "66", "y": "9F" }, { "x": "69", "y": "A2" }, { "x": "72", "y": "A8" }, { "x": "74", "y": "AA" }, { "x": "77", "y": "AC" }, { "x": "79", "y": "AE" }, { "x": "7C", "y": "AF" }, { "x": "7E", "y": "B1" }, { "x": "80", "y": "B2" }, { "x": "82", "y": "B4" }, { "x": "85", "y": "B5" }, { "x": "87", "y": "B5" }, { "x": "89", "y": "B6" }, { "x": "90", "y": "B6" }, { "x": "95", "y": "B3" }, { "x": "97", "y": "B1" }, { "x": "99", "y": "AD" }, { "x": "9B", "y": "AC" }, { "x": "9D", "y": "A7" }, { "x": "9F", "y": "A4" }, { "x": "A2", "y": "9B" }, { "x": "A3", "y": "97" }, { "x": "A3", "y": "93" }, { "x": "A4", "y": "90" }, { "x": "A4", "y": "8C" }, { "x": "A5", "y": "87" }, { "x": "A5", "y": "77" }, { "x": "A6", "y": "73" }, { "x": "A6", "y": "67" }, { "x": "A7", "y": "63" }, { "x": "A7", "y": "60" }, { "x": "A9", "y": "5A" }, { "x": "A9", "y": "56" }, { "x": "AD", "y": "49" }, { "x": "AD", "y": "47" }, { "x": "AF", "y": "44" }, { "x": "B2", "y": "3A" }, { "x": "B3", "y": "36" }, { "x": "B6", "y": "2F" }, { "x": "BB", "y": "27" }, { "x": "BD", "y": "26" }, { "x": "BE", "y": "24" }, { "x": "C0", "y": "23" }, { "x": "C2", "y": "21" }, { "x": "C4", "y": "20" }, { "x": "C9", "y": "20" }, { "x": "FFFF", "y": "FFFF" }] }

Do I need to parse this to turn it in to a jpg, or is there a way I could use PIL (or another library) to turn this set of plots in to an image?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source