如何在Python中将两个SVG图像堆叠在一起?

时间:2018-05-29 16:35:11

标签: python image svg

我正在制作一个结合了几张图片的应用。 应用程序应将图像堆叠在一起。 起初我使用PNG并使用PIL很简单,只是:

first_layer_image.paste(second_layer_image, (0,0), second_layer_image)

如何使用SVG做同样的事情? 例如,这里只有两个SVG图像中的两个我想叠加在一起。

First layer image:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4000 4000">
<defs>
    <style>.cls-1{fill:#755841;}.cls-2{fill:#f7c394;}.cls-3{fill:#9b7657;}.cls-4{fill:#7f6145;}.cls-5{fill:#ffc9a1;}.cls-6{fill:#ffcd98;}.cls-7{fill:#3d0c0c;}.cls-8{fill:#fff;}.cls-9{fill:#313cc4;}</style>
</defs>
<title>expanded</title>
<g id="expanded">
    <path class="cls-1" d="M1685.94,3103.49a46.66,46.66,0,0,1-46.27-41.15c-7.68-64.58,15.14-139.41,64.25-210.71,43-62.41,102.73-116.13,159.81-143.72a46.66,46.66,0,1,1,40.6,84c-42.51,20.54-89.86,63.7-123.56,112.64-35.71,51.83-53.36,105.32-48.44,146.75a46.65,46.65,0,0,1-40.82,51.84A47.68,47.68,0,0,1,1685.94,3103.49Z" />
    <path class="cls-2" d="M1698.65,3195a54.69,54.69,0,0,1-19.13-3.46c-16.08-6-29-18.39-38.52-36.88a116,116,0,0,1-11.55-36.67c-4.12-30.82,6.37-57.71,28.78-73.76a54.89,54.89,0,0,1,83.92,62.36,54.91,54.91,0,0,1-43.5,88.41Z" />
    <path class="cls-3" d="M2254,3205.38a158.15,158.15,0,0,1-22.69-1.75c-39-5.71-88.52-24.82-151.33-58.42a18.93,18.93,0,1,1,17.86-33.39c129.79,69.42,172.74,59.15,186.78,46.84,10.58-9.26,9.64-25.54,6.89-55.92-3.21-35.45-7.19-79.56,15.19-130.25,17-38.39,46.73-75,81.7-100.39,40.59-29.51,83.81-41.73,125-35.36,26.53,4.1,53.15,16,74.94,33.57,25,20.14,41.51,45.85,47.69,74.35,5.06,23.34,3.71,51.06-3.62,74.15-9.4,29.64-28.13,50.84-52.75,59.68a78.83,78.83,0,0,1-26.81,4.62c-37.89,0-69.36-25.67-73.53-29.22a18.94,18.94,0,0,1,24.56-28.84c.33.28,33.72,28.3,63,17.8,17-6.1,25.39-22.67,29.45-35.49,5.33-16.81,6.37-37.76,2.7-54.68-5.46-25.19-21.73-42.65-34.42-52.86-16.45-13.25-37.22-22.6-57-25.65-67.11-10.39-138.54,50.89-166.24,113.62-18.43,41.73-15.08,78.81-12.12,111.54,3,33.64,5.92,65.43-19.65,87.82C2295.74,3199.28,2277.1,3205.38,2254,3205.38Z" />
    <path class="cls-1" d="M1877.5,3396.06c-.93,0-1.85,0-2.79,0a68.61,68.61,0,0,1-65.82-71.3c3.54-88.69,25.64-150.48,41.77-195.59,4.87-13.62,9.07-25.38,12.13-35.94a68.61,68.61,0,1,1,131.83,38.09c-4.24,14.66-9.34,28.94-14.75,44.05-14.6,40.85-31.16,87.15-33.86,154.87A68.61,68.61,0,0,1,1877.5,3396.06Z" />
    <path class="cls-2" d="M1761.27,3431A54.9,54.9,0,0,1,1739,3325.93c71.38-31.61,167.74-20.26,211.71-5.67a54.89,54.89,0,1,1-34.57,104.2c-26.37-8.75-93.26-15.61-132.68,1.85A54.74,54.74,0,0,1,1761.27,3431Z" />
    <path class="cls-1" d="M2126.63,3397.47a68.62,68.62,0,0,1-68.44-64.68c-3.88-67.66-21.24-113.66-36.56-154.25-5.67-15-11-29.21-15.51-43.79a68.61,68.61,0,1,1,131.15-40.38c3.23,10.5,7.64,22.19,12.75,35.72,16.92,44.82,40.09,106.22,45.18,194.83a68.63,68.63,0,0,1-64.57,72.44C2129.29,3397.43,2128,3397.47,2126.63,3397.47Z" />
    <path class="cls-2" d="M2243.71,3430.39a54.73,54.73,0,0,1-21.32-4.33c-39.72-16.77-106.49-8.74-132.7.47A54.89,54.89,0,0,1,2053.31,3323c43.71-15.35,139.86-28.39,211.78,2a54.9,54.9,0,0,1-21.38,105.47Z" />
    <path class="cls-1" d="M2319.74,3100c-1.57,0-3.15-.08-4.75-.24a46.65,46.65,0,0,1-41.72-51.12c4.2-41.51-14.39-94.68-51-145.89-34.55-48.34-82.65-90.66-125.52-110.46a46.66,46.66,0,0,1,39.14-84.72c57.55,26.59,118.22,79.27,162.29,140.92,50.35,70.42,74.47,144.84,67.92,209.54A46.68,46.68,0,0,1,2319.74,3100Z" />
    <path class="cls-2" d="M2308.5,3191.69a54.91,54.91,0,0,1-44.08-87.65,54.89,54.89,0,0,1,82.82-63.82c22.68,15.67,33.64,42.36,30.06,73.25-3.1,26.72-17.74,62.24-48.78,74.42A54.75,54.75,0,0,1,2308.5,3191.69Z" />
    <path class="cls-4" d="M2022.92,2587.06c42.55,2.61,71.85,33.56,97.82,61.77,30.25,32.86,61.64,80.35,91.53,188.7,30.31,109.82,45.46,164.73,35.3,219.17-18.54,99.29-108.22,240.16-246.14,241.35-135,1.16-227.85-132.32-245.4-235.87-9.36-55.22,9.73-111.76,47.9-224.85,37-109.75,71.21-154,96.79-180.86C1929.58,2626.18,1970,2583.8,2022.92,2587.06Z" />
    <path class="cls-2" d="M2001.18,2616.45c31.58-.27,63.25,39.89,87.37,81.71a492.72,492.72,0,0,1,54.28,139.52c25,114.06,41.72,190.61-4.63,248.56-46.09,57.6-126.39,59.74-136.77,59.85-10.83.11-89.18-.39-134.63-57-45.26-56.38-26.74-131.75,2.7-251.54,3-12.29,29.46-79.84,73.41-161.79C1956.93,2649.61,1975.87,2616.67,2001.18,2616.45Z" />
    <path class="cls-2" d="M865.5,1836.78c-109.3,103.92-60.91,310.4,16.55,426.94,110.37,166.07,358.19,267.53,482.6,176,129.93-95.63,107.63-388.85-48.61-538.55C1199.4,1789.37,978.54,1729.31,865.5,1836.78Z" />
    <path class="cls-5" d="M997.27,1954.6c-64.75,69.33-26.65,197.17,26.33,267.46,75.51,100.15,234.91,154.61,309.6,92.47,78-64.9,53.07-248.18-50.62-336.34C1205.16,1912.36,1064.24,1882.9,997.27,1954.6Z" />
    <path class="cls-2" d="M3134.89,1832.12c111.1,102,66.32,309.29-9.09,427.16-107.46,168-353.47,273.75-479.45,184.37-131.58-93.35-114.4-386.92,39.19-539.32C2800.22,1790.55,3020,1726.64,3134.89,1832.12Z" />
    <path class="cls-5" d="M3005.2,1952.22c66,68.19,30.09,196.68-21.66,267.88-73.75,101.45-232.17,158.69-307.94,97.86-79.14-63.53-57.39-247.22,44.75-337.18C2796.61,1913.62,2937,1881.7,3005.2,1952.22Z" />
    <path class="cls-4" d="M2542.19,829.7c38.86-39.54-134.68-124.74-135.25-190.15-.71-81,405.3,171.58,324.16,314.14-17.58,30.89-63.48,112.31-461.63-16.87C2667.62,1066,2967.62,1340,2966.2,1847.06c-1.09,388.75-348.57,990.75-964.93,996.12-594.62,5.19-966-596.16-964.93-996.12,1.33-488.44,432.35-989.27,966.09-1028.56C2398.25,789.36,2494.38,878.36,2542.19,829.7Z" />
    <path class="cls-6" d="M2001.27,1320.55c19.15-.16,112.39-116.75,268-116.74,223.53,0,482,324.76,482.28,643.25.16,205.85-111.65,252-111.45,275.69.19,21.13,236.88,22.58,236.88,254.71,0,209.25-420.37,512-840.86,524.16-461.31,13.34-910.31-319.74-910.31-497.74,0-232.44,237-260.58,236.85-281.27s-111.76-76.15-111.93-275.55c-.26-318.49,259.27-643.25,482.47-643.25C1905.63,1203.8,1978.54,1320.75,2001.27,1320.55Z" />
    <path class="cls-7" d="M2600.16,2330.77c32.4-4.6,56,22.77,47.08,55.45-11.75,43.09-35,85.68-67.74,125.82q-11.17,13.73-23.87,27c-115.49,121.69-320.37,213.48-554.36,213.08-234,.4-438.88-91.39-554.37-213.08q-12.66-13.29-23.86-27c-32.78-40.14-56-82.73-67.75-125.83-8.9-32.67,14.68-60,47.08-55.44A4258.57,4258.57,0,0,0,2600.16,2330.77Z" />
    <path class="cls-7" d="M2002.74,2770.57h-3c-112.73,0-225.78-21.46-327-62.09-95.65-38.4-178.38-92.6-239.24-156.73-8.78-9.21-17.13-18.66-24.79-28.07-34.94-42.79-58.91-87.41-71.23-132.62-6-21.92-1.44-43.51,12.45-59.24,13.5-15.31,33.55-22.34,55-19.29a4240,4240,0,0,0,596.3,42.15,4238.47,4238.47,0,0,0,596.3-42.15h0c21.44-3.05,41.49,4,55,19.29,13.88,15.73,18.42,37.32,12.45,59.24-12.32,45.19-36.29,89.82-71.25,132.63-7.72,9.48-16.07,18.93-24.81,28.09-60.83,64.1-143.56,118.3-239.21,156.7C2228.58,2749.11,2115.53,2770.57,2002.74,2770.57Zm-1.5-36.85h1.44c108.2,0,216.48-20.54,313.34-59.44,90.77-36.44,169-87.59,226.25-147.9,8.11-8.51,15.82-17.23,22.95-26,31.68-38.81,53.29-78.85,64.25-119,2.65-9.73,1-18.9-4.53-25.17-5.23-5.92-13.11-8.47-22.18-7.18h0a4275.86,4275.86,0,0,1-1203,0c-9.07-1.29-17,1.26-22.18,7.18-5.53,6.27-7.18,15.44-4.53,25.17,11,40.19,32.57,80.24,64.24,119,7.07,8.68,14.78,17.41,22.93,26,57.27,60.34,135.5,111.49,226.27,147.94,96.86,38.88,205.16,59.43,313.29,59.43Z" />
    <path class="cls-8" d="M2647.24,2386.21c-11.75,43.09-35,85.69-67.74,125.83q-36.18,5-72.44,9.29-6.66.81-13.33,1.58a4258.51,4258.51,0,0,1-968,1.93q-8.94-1-17.87-2.06h0q-42.43-4.94-84.78-10.74c-32.77-40.14-56-82.73-67.74-125.83-8.89-32.67,14.68-60,47.08-55.44q7.83,1.11,15.65,2.19,7.37,1,14.74,2a4258.61,4258.61,0,0,0,1153.34-2.23l10.12-1.41,3.94-.56C2632.55,2326.17,2656.14,2353.54,2647.24,2386.21Z" />
    <path class="cls-8" d="M2555.63,2539.06c-48.1,50.68-111.69,96.17-186.44,132a795,795,0,0,1-90.22,36.51c-84.24,28.31-178.35,44.76-277.7,44.59a874.36,874.36,0,0,1-243.1-33.8s0,0,0,0a814.34,814.34,0,0,1-94.37-33.52c-88-37.57-162.38-88.32-216.88-145.75q40.57,5.33,81.21,9.87c5.18.57,10.36,1.15,15.55,1.7a4258,4258,0,0,0,932.17-1.87q5.51-.62,11-1.25Q2521.27,2543.58,2555.63,2539.06Z" />
    <path class="cls-8" d="M1760,1403.06c154.89,18,266.48,208.75,250,376.77-16.39,167.34-162.7,342-329.89,323-151.79-17.3-250.26-186.22-253.5-328.16C1422.3,1584.51,1587.45,1383,1760,1403.06Z" />
    <ellipse class="cls-9" cx="1770.53" cy="1790.92" rx="210.18" ry="180.94" transform="translate(-324.93 3187.77) rotate(-79.02)" />
    <ellipse cx="1781.54" cy="1823.1" rx="105.94" ry="118.46" />
    <ellipse class="cls-8" cx="1835.31" cy="1726.3" rx="40.43" ry="42.42" transform="translate(-404.49 2880.33) rotate(-70.51)" />
    <path class="cls-8" d="M2235.68,1398.91c-154.55,20.68-262.79,213.36-243.41,381.08,19.3,167,168.63,339.1,335.47,317.13,151.47-19.94,247-190.55,247.73-332.52C2576.49,1574.44,2407.84,1375.87,2235.68,1398.91Z" />
    <ellipse class="cls-9" cx="2231.91" cy="1786.89" rx="180.94" ry="210.18" transform="translate(-322.39 502.39) rotate(-11.98)" />
    <ellipse cx="2221.47" cy="1819.26" rx="105.94" ry="118.46" transform="translate(-31.41 39.05) rotate(-1)" />
    <ellipse class="cls-8" cx="2275.94" cy="1726.33" rx="42.42" ry="40.43" transform="translate(-460.36 906.08) rotate(-20.49)" />
    <path class="cls-4" d="M1785.75,2081.38c0,75.28,98.57,166.65,215.68,165.63,107.93-.94,213.18-91.24,213.18-165.41,0-59.68-124.17-112.16-213.18-111.39C1918.8,1970.93,1785.75,2010.78,1785.75,2081.38Z" />
</g>
</svg>

第二层图片:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4000 4000">
<defs>
    <style>.cls-1{opacity:0.05;}.cls-2{opacity:0.1;}.cls-3{opacity:0.2;}.cls-4{opacity:0.08;}</style>
</defs>
<title>shader</title>
<g id="shader">
    <path class="cls-1" d="M1850,1434.82a211.94,211.94,0,0,0-49.86-12.11c-172.54-20-337.7,181.45-333.37,371.56,2.51,110,62.25,236.26,159.68,295.51-121-45.56-197-190.72-199.85-315.16C1422.3,1584.51,1587.45,1383,1760,1403.06,1792.12,1406.79,1822.38,1418,1850,1434.82Z" />
    <path class="cls-1" d="M2575.47,1764.59c-.67,124.47-74.15,271-194.33,318.62,96.39-61,153.92-188.21,154.5-298.27,1-190.16-167.63-388.72-339.79-365.68a212.08,212.08,0,0,0-49.68,13c27.35-17.35,57.43-29,89.5-33.34C2407.84,1375.87,2576.48,1574.44,2575.47,1764.59Z" />
    <path class="cls-2" d="M1869.31,1609a158.22,158.22,0,0,0-18.56-4.78c-98.1-19-195.56,57.9-217.67,171.85-17.27,89,16.5,174.22,78.84,216.37-87.16-28.22-139.71-129.44-119-236,22.12-114,119.58-190.89,217.68-171.85A158.2,158.2,0,0,1,1869.31,1609Z" />
    <path class="cls-2" d="M2294.05,1987.37c61.58-43.24,93.85-129,75-217.7-24.1-113.55-122.89-188.78-220.64-168a156.86,156.86,0,0,0-18.48,5.11,158.48,158.48,0,0,1,58.3-25.46c97.76-20.75,196.54,54.48,220.65,168C2431.45,1855.52,2380.68,1957.62,2294.05,1987.37Z" />
    <path class="cls-3" d="M2214.61,2081.59c0,74.18-105.25,164.48-213.18,165.42-117.12,1-215.68-90.36-215.68-165.63a55.33,55.33,0,0,1,1.46-12.65c39.94,53.41,121.8,99,214,98.28,85.64-.67,169.74-46.83,210.9-100.17A45.83,45.83,0,0,1,2214.61,2081.59Z" />
    <path class="cls-4" d="M1097,2439.73c-83.85-36.5-164-99.38-215-176-77.46-116.54-125.85-323-16.55-426.93,45.17-43,107.55-59.14,173.62-56q-.82,10.15-1.4,20.33c-50.28,4.26-96.49,21.49-132,55.29-109.31,103.91-60.91,310.39,16.54,426.93C964.94,2347.64,1028.26,2402.24,1097,2439.73Z" />
    <path class="cls-4" d="M3125.8,2259.28c-49.63,77.57-128.8,141.88-212.06,179.83,68.19-38.68,130.6-94.42,172.23-159.49,75.41-117.87,120.2-325.16,9.09-427.16-35.33-32.43-80.57-48.85-129.62-52.73q-.36-10.47-.91-20.79c64.45-3.41,125.43,11.93,170.36,53.18C3246,1934.11,3201.21,2141.4,3125.8,2259.28Z" />
    <path class="cls-2" d="M2247.57,3056.69C2229,3156,2139.35,3296.86,2001.43,3298c-135,1.16-227.85-132.31-245.4-235.86a178.64,178.64,0,0,1-1.42-47.38c.3,2.46.65,4.92,1.07,7.38,17.55,103.55,110.38,237,245.4,235.86,137.92-1.18,227.6-142.05,246.14-241.34,1.07-5.76,1.87-11.52,2.38-17.35C2251.54,3019.91,2251,3038.33,2247.57,3056.69Z" />
    <g class="cls-3">
        <path d="M2267.51,3173.33c-11.06,5.09-30.83,7.25-66-2.54q3.45-5.48,6.65-11c24.86,7.24,42.33,8.69,54.58,7.3A52.66,52.66,0,0,0,2267.51,3173.33Z" />
        <path d="M2566.83,3042.84a38.52,38.52,0,0,0,9.66-5.13,41.64,41.64,0,0,1-19.57,15.22c-29.25,10.51-62.64-17.51-63-17.8a18.94,18.94,0,0,0-19.87-2.93,19.13,19.13,0,0,1,3.08-5,18.94,18.94,0,0,1,26.7-2.14C2504.19,3025.33,2537.58,3053.35,2566.83,3042.84Z" />
        <path d="M2632.39,3018.8c-6,19.09-16,34.68-28.85,45.72a105.14,105.14,0,0,0,18.94-35.63c7.32-23.08,8.67-50.8,3.61-74.15-6.17-28.49-22.66-54.2-47.68-74.34-21.8-17.55-48.41-29.47-74.94-33.58-41.18-6.37-84.4,5.86-125,35.36a247,247,0,0,0-26.12,22,250.49,250.49,0,0,1,36-32.06c40.59-29.5,83.81-41.72,125-35.36,26.53,4.11,53.14,16,74.94,33.58,25,20.14,41.51,45.85,47.69,74.34C2641.06,2968,2639.71,2995.72,2632.39,3018.8Z" />
    </g>
    <path class="cls-1" d="M1360.7,2126.07c11.9-10.67-113.73-80.72-109.94-279,.11-5.45.07-10.91.22-16.37,8.5,180.23,141.67,258.15,141.84,277.92C1392.85,2112.33,1373.28,2120.71,1360.7,2126.07Z" />
    <path class="cls-1" d="M2610.35,2101.65c-.2-23.12,135.56-86.47,140.69-279.55.35,8.32.14,16.65.54,25,9.56,197.82-123.27,264.93-110.31,278.16C2627.73,2121,2610.39,2105.61,2610.35,2101.65Z" />
    <path class="cls-4" d="M2877,2377.46c0,209.25-420.37,512-840.86,524.16-461.31,13.34-910.31-319.75-910.31-497.75q0-12.16.85-23.59c25.71,181.25,461.62,494.28,909.11,481.34,410.88-11.88,821.64-301.22,840.2-509.67Q2877,2364.22,2877,2377.46Z" />
    <path class="cls-4" d="M1730.65,3184.68a54.77,54.77,0,0,1-51.13,6.84c-16.08-6-29-18.39-38.52-36.88a116,116,0,0,1-11.55-36.67c-2.74-20.52,1-39.29,10.41-54.29-.07-.45-.14-.89-.19-1.35-7.55-63.51,14.39-136.94,61.84-207.16q9.77,2.91,19.62,5.67c-40.3,65.3-59.68,119-52.7,177.78,0,.46-.06-.45,0,0-9.41,15-11.81,48.57-9.07,69.09a116.08,116.08,0,0,0,11.55,36.67c9.48,18.49,22.44,30.9,38.52,36.88a54.69,54.69,0,0,0,19.13,3.46C1729.26,3184.72,1730,3184.71,1730.65,3184.68Z" />
    <path class="cls-4" d="M2377.29,3113.47c-3.09,26.72-17.73,62.24-48.78,74.41a54.79,54.79,0,0,1-51.25-6c.38,0,.77,0,1.15,0a55,55,0,0,0,20-3.8c31.05-12.18,45.68-47.7,48.78-74.42,2.38-20.56-.59-54.27-10.26-69.11.06-.44,0,.46,0,0,5.81-57.38-13.43-108.74-52.78-171.85q10-2.79,20-5.76c46.28,67.88,68.24,138.92,62,201-.05.46-.11.9-.17,1.35C2375.61,3074.2,2379.68,3092.91,2377.29,3113.47Z" />
    <path class="cls-4" d="M1985.53,3389.64a54.89,54.89,0,0,1-69.38,34.82c-26.37-8.75-93.26-15.62-132.68,1.84a54.92,54.92,0,0,1-77-46.67,54.85,54.85,0,0,0,71.84,26.72c39.42-17.46,106.32-10.6,132.69-1.85a54.9,54.9,0,0,0,72.06-55.64A54.7,54.7,0,0,1,1985.53,3389.64Z" />
    <path class="cls-4" d="M2298.58,3378a54.86,54.86,0,0,1-76.19,48c-39.72-16.76-106.49-8.73-132.71.47a54.89,54.89,0,0,1-68.2-74.4,54.91,54.91,0,0,0,73,54.36c26.22-9.21,93-17.24,132.7-.47a54.83,54.83,0,0,0,71.37-28Z" />
    <path class="cls-4" d="M2138.19,3086.24c-46.08,57.6-126.38,59.74-136.76,59.84-10.83.12-89.18-.38-134.63-57-21.19-26.39-28.4-57-27.06-94.28,1.63,28.47,9.6,52.76,26.88,74.28,45.46,56.63,123.81,57.13,134.63,57,10.38-.11,90.69-2.25,136.77-59.85,19.78-24.72,28.06-52.83,29.13-85.79C2169.07,3022.24,2161.85,3056.66,2138.19,3086.24Z" />
    <path class="cls-2" d="M2750.8,1816.91c-15.74-308.51-265-613.11-481.5-613.11-155.64,0-248.88,116.58-268,116.75-22.73.2-95.64-116.75-268-116.75-218.18,0-471.06,310.31-482.1,621.74q-.78-13.72-.81-28.48c-.26-318.49,259.27-643.25,482.47-643.26,172.41,0,245.31,117,268,116.75,19.15-.17,112.39-116.75,268-116.75,223.52,0,482,324.77,482.27,643.26Q2751.16,1807.25,2750.8,1816.91Z" />
    <path class="cls-2" d="M2473.67,674.35c-.15-17.72,8.93-28.23,62.15-5.43-69.23-42.34-129.15-60.54-128.88-29.37.57,65.4,174.11,150.61,135.25,190.15-47.82,48.66-143.94-40.34-539.76-11.2-533.75,39.29-964.77,540.12-966.09,1028.56-.35,129.83,38.54,280.85,111.58,425.48v0l1.29,2.52q1.86,3.66,3.74,7.3c.87-1.71,1.76-3.39,2.66-5.06l.66-1.21q2.73-5,5.66-9.77l.66-1.08q1.44-2.33,2.93-4.61l0-.08c1-1.56,2-3.09,3.1-4.61l.69-1q1.5-2.16,3-4.26l.15-.21q1.6-2.19,3.25-4.33c.25-.33.5-.66.76-1q1.5-1.95,3-3.85l.31-.39q1.65-2,3.33-4l.9-1q1.44-1.68,2.89-3.31l.61-.69c70.21-78.43,175.19-95.5,175.07-109.27,0-3.27-2.87-7.43-7.63-12.9-25.54,13.92-113.62,31-172.71,99.27-46.31-115.84-85.59-250.75-85.31-351.82,1.33-488.44,452-960.07,985.73-999.36,395.82-29.14,491.95,59.86,539.77,11.2C2661.39,829.46,2474.24,739.75,2473.67,674.35Z" />
    <path class="cls-2" d="M2966.2,1847.06c1.35-482.72-270.46-754.2-640.08-890.61-86.12-31.59-74.29-16.76-109.17-28.08,398.15,129.18,710.58,402,709.16,909-.32,115-27.37,241.26-86.32,372.62-57.8-80.49-163.52-88.39-192.17-100.84-4.72,5.46-7.52,9.79-7.49,13.56.13,15.13,121.52,20.18,190.45,107h0q5.36,6.73,10.25,14.14l0,0c1.08,1.63,2.13,3.28,3.17,5l0,.08c1,1.68,2.05,3.38,3,5.1a.41.41,0,0,1,.05.09q1.5,2.6,2.93,5.26l0,.07c1,1.79,1.89,3.6,2.81,5.45l0,0q1.38,2.77,2.7,5.64c1.5-3,3-6.05,4.48-9.09h0C2929.62,2119.3,2965.85,1972.14,2966.2,1847.06Z" />
    <path class="cls-2" d="M1949.22,3291.58c-.57,4.42-1.08,8.93-1.52,13.56-50.19-13.56-92.55-45.85-124.81-85.56q1.26-5.46,2.59-10.73C1857.73,3247.49,1899.7,3278.64,1949.22,3291.58Z" />
    <path class="cls-2" d="M2178.62,3217.15h0c-31.79,39.62-73.27,72.47-123,86.94q-.84-6.9-1.87-13.49c49.09-13.81,90.24-45.54,122-84.13Q2177.25,3211.71,2178.62,3217.15Z" />
    <path class="cls-2" d="M2194,3308c-52.67-5-105.6,3.5-136.57,13.54q-.4-4.95-.91-9.74c30.69-10.1,83.68-18.74,136.52-13.88Q2193.55,3302.92,2194,3308Z" />
    <path class="cls-2" d="M1947.33,3309.2c-.28,3.2-.52,6.45-.74,9.75-31.15-9.5-84.22-17.07-136.78-11.17.23-3.4.49-6.77.78-10.09C1863.34,3291.92,1916.47,3299.63,1947.33,3309.2Z" />
    <path class="cls-1" d="M1512.69,2523.35l-4.87-.57h0q-42.43-4.94-84.78-10.74c-32.77-40.15-56-82.73-67.74-125.83-8.9-32.68,14.68-60.05,47.08-55.44,5.22.73,10.43,1.47,15.65,2.19l2.44.33C1439.87,2399.23,1469.68,2463.73,1512.69,2523.35Z" />
    <path class="cls-1" d="M1740.15,2712.92a810.14,810.14,0,0,1-76.37-28.11c-88-37.57-162.38-88.33-216.88-145.75q40.57,5.33,81.21,9.86l1.48.16C1582.24,2611.78,1651.21,2667.87,1740.15,2712.92Z" />
    <path class="cls-1" d="M2647.24,2386.21c-11.75,43.09-35,85.68-67.74,125.83q-36.18,5-72.45,9.29l-11.58,1.37c41.19-59.77,69.41-124,87.46-189.53l3.16-.43,10.13-1.42,3.94-.55C2632.55,2326.16,2656.14,2353.53,2647.24,2386.21Z" />
    <path class="cls-1" d="M2555.63,2539.06c-48.1,50.68-111.69,96.17-186.44,132a790.65,790.65,0,0,1-74.71,31.12c75.86-43.85,135.64-96,182.09-153.34l1.48-.19,7.14-.93,1.67-.19Q2521.26,2543.58,2555.63,2539.06Z" />
    <path class="cls-2" d="M2304.15,2857q-39.86,11.91-80.78,20.95-8.65,1.92-17.35,3.68-25.77,5.23-51.81,9.2a972.49,972.49,0,0,1-118.06,10.79,1000.28,1000.28,0,0,1-179.37-11.42q-29-4.41-57.48-10.33c-3-.62-6-1.26-9-1.9q-45.07-9.72-88.76-22.8-8.44,12.48-15.79,25.09c30.82,9.66,62.31,18.19,94.3,25.39l.74-1.09,1.46-2.1c-.38,1.15-.75,2.3-1.11,3.43q34.26,7.68,69.24,13.27a1002.45,1002.45,0,0,0,186.06,12.46A975.24,975.24,0,0,0,2159.79,2920q33.12-5.21,65.84-12.5c1.77-.39,3.54-.78,5.3-1.19q45.21-10.26,89.19-24.13Q2312.7,2869.55,2304.15,2857Z" />
</g>
<g id="outline_shader" data-name="outline+shader">
    <path class="cls-2" d="M2214.79,2101.6c0,74.18-105.25,164.48-213.18,165.42-117.12,1-215.68-90.36-215.68-165.63q0-1.65.09-3.27c0-.3.06-.59.08-.89.06-.78.12-1.55.21-2.32,0-.35.1-.69.15-1s0-.41.08-.62c9.52,72.67,103.87,154.73,214.89,153.76,102.62-.89,202.81-82.57,212.43-154.36,0,.13,0,.26.08.39s0,.28.07.41a44.2,44.2,0,0,1,.66,5.1l0,.5C2214.75,2099.9,2214.79,2100.75,2214.79,2101.6Z" />
</g>
</svg>

2 个答案:

答案 0 :(得分:1)

import svgutils.transform as st

template = st.fromfile('firstLayer.svg')
second_svg = st.fromfile('secondLayer.svg')
template.append(second_svg)
template.save('merged.svg')

这是来自another post的解决方案。

问题是您需要为每个文件选择不同的类名,否则每个文件中的样式将相互干扰。例如,第一个文档中的cls-1类也将从第二个文档中应用opacity:0.05

secondLayer.svg将是您追加的文件,因为附加它将意味着它在文档的下方,对于SVG意味着它将位于顶部。

答案 1 :(得分:0)

继续上一个答案的建议。我没有找到一个已经制作好的Python解决方案来重写每个路径的元素和类属性中的类名,所以我自己创建了一个

https://github.com/Amirh24/SVGAppender

随意使用它:)