This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
The TL;DR is that you cannot with PNGs or JPEGs but might be able to get some semblance of the original image if you use SVGs.
A JPEG or PNG gives the color values pixel by pixel so it's near impossible to get any polyline or polygon information from them - you could use some form of edge detection but that would be beyond me and probably more trouble than it's worth. An SVG, however, is a vector graphic that contains the path information in the file.
Here's an example of an SVG (original on the left and simplified using graphics software on the right just to get the edge information)
If you open up the SVG in a text editor you can see the path information (which has all the coordinates) is in the form of XML.
SVG in the form of XML
Since the SVG is XML you can input the spiderman.svg file into a workflow as XML then parse out the coordinates, create points and create a polyline,
What I haven't solved for is that SVG path is often represented as a Bezier curve and I'm only able to create straight lines from point to point. Maybe one day I'll learn to interpolate the points so Spiderman doesn't look so angular.
I tried converting your image to an SVG (there are some free tools on the internet that do this) but the results weren't pretty.