Note that there are some explanatory texts on larger screens.

plurals
  1. PORead SVG file with Python/PIL
    text
    copied!<p>I'm new to Python so please be patient with me. <br> Basically my script should run like this:</p> <p>1) Load an image and split it into R, G, B channels<br> 2) Mark an area of that image with an existing path saved as a svg file and <br> 3) perform some calculations with the R,G,B values of this area.<br> (further send the the image either to folder A or B, depending on the outcome of the calc)</p> <p>I've done 1) and parts of 3) but my current problem is to load the svg file and apply it on my image.<br> The image is a photograph taken with a fisheye lens. I just want to get the RGB-values of the actual photograph - not the black background. I created the svg file by drawing the desired path with GIMP (not a circle).</p> <p>My question is: <br> How to load an existing svg-file (and read it as a path) with python and apply the path onto an image?</p> <p>I'm sure there is a simple way to do that, but I haven't found it yet.</p> <p>Any hints and reccommendations will be appreciated!</p> <hr> <p>Edit:</p> <p>The svg file:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt; &lt;!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" `"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"&gt; &lt;svg xmlns="http://www.w3.org/2000/svg" width="22.2222in" height="16.6667in" viewBox="0 0 1600 1200"&gt; &lt;path id="Auswahl" fill="none" stroke="black" stroke-width="1" d="M 848.00,103.21 C 848.00,103.21 861.00,103.96 861.00,103.96 891.77,105.30 921.91,109.93 952.00,116.58 988.30,124.59 1023.25,137.24 1057.00,152.69 1210.78,223.11 1322.55,368.09 1353.61,534.00 1358.02,557.54 1361.00,581.11 1362.04,605.00 1362.04,605.00 1363.00,616.00 1363.00,616.00 1363.00,616.00 1363.00,649.00 1363.00,649.00 1363.00,649.00 1362.04,662.00 1362.04,662.00 1360.12,705.99 1352.05,749.92 1338.98,792.00 1289.63,950.77 1167.62,1077.58 1011.00,1133.31 962.90,1150.42 911.98,1160.82 861.00,1163.04 861.00,1163.04 848.00,1164.00 848.00,1164.00 848.00,1164.00 815.00,1164.00 815.00,1164.00 815.00,1164.00 804.00,1163.04 804.00,1163.04 756.47,1160.97 709.15,1151.72 664.00,1136.67 608.47,1118.16 556.55,1090.63 510.00,1055.12 469.68,1024.36 434.97,988.81 404.88,948.00 288.05,789.50 269.64,577.90 355.26,401.00 418.58,270.18 535.32,170.13 674.00,127.02 700.27,118.86 729.73,111.96 757.00,108.28 757.00,108.28 795.00,104.17 795.00,104.17 795.00,104.17 809.00,103.21 809.00,103.21 809.00,103.21 848.00,103.21 848.00,103.21 Z" /&gt; &lt;/svg&gt; </code></pre> <p>And the link to the image: <a href="http://img153.imageshack.us/img153/5330/skybig.jpg" rel="nofollow noreferrer">http://img153.imageshack.us/img153/5330/skybig.jpg</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload