Inkscape

Script inkscape plusieurs images dans un calque


<?py

WHAT IT DOES
This script import several photos and place them each on a layer.


HOW TO USE:
- place all pictures in a directory
- be sure there is no space in the file names : rename ’s/ /_/g’ img/*
- if needed, resize all images for i in * ; do convert -geometry 1250 "$i" "th_$i" ;
done
- launch ls * | python mkimglayers.py >mondocument.svg
- open in inkscape
'''

import sys
import re
from PIL import ImageFont

print ("""<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:cc="http://creativecommons.org/ns#"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:svg="http://www.w3.org/2000/svg"
  xmlns="http://www.w3.org/2000/svg"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
  xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
  width="744.09448819"
  height="1052.3622047"
  id="svg2"
  sodipodi:version="0.32"
  inkscape:version="0.46"
  sodipodi:docname="test.svg"
  inkscape:output_extension="org.inkscape.output.svg.inkscape">
 <defs
    id="defs4">
   <inkscape:perspective
      sodipodi:type="inkscape:persp3d"
      inkscape:vp_x="0 : 526.18109 : 1"
      inkscape:vp_y="0 : 1000 : 0"
      inkscape:vp_z="744.09448 : 526.18109 : 1"
      inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
      id="perspective10" />
   <inkscape:perspective
      id="perspective2464"
      inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
      inkscape:vp_z="744.09448 : 526.18109 : 1"
      inkscape:vp_y="0 : 1000 : 0"
      inkscape:vp_x="0 : 526.18109 : 1"
      sodipodi:type="inkscape:persp3d" />
 </defs>
 <sodipodi:namedview
    id="base"
    pagecolor="#ffffff"
    bordercolor="#666666"
    borderopacity="1.0"
    gridtolerance="10000"
    guidetolerance="10"
    objecttolerance="10"
    inkscape:pageopacity="0.0"
    inkscape:pageshadow="2"
    inkscape:zoom="0.35"
    inkscape:cx="375"
    inkscape:cy="520"
    inkscape:document-units="px"
    inkscape:current-layer="layer1"
    showgrid="false"
    inkscape:window-width="1024"
    inkscape:window-height="736"
    inkscape:window-x="1024"
    inkscape:window-y="1" />
 <metadata
    id="metadata7">
   <rdf:RDF>
     <cc:Work
        rdf:about="">
       <dc:format>image/svg+xml</dc:format>
       <dc:type
          rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
     </cc:Work>
   </rdf:RDF>
 </metadata>    
""" )
lines = sys.stdin.readlines()
i=1
for line in lines:
   print '<g'
   print 'inkscape:label="images"'
   print 'inkscape:groupmode="layer"'
   print 'id="layer1">'
   print  '<image'
   print  ' id="%s"' % (line.strip())
   print  ' xlink:href="%s" />' % (line.strip())
   print '</g>'
print ("""
</svg>
""")




?>

Merci à Cédric pour ces petites lignes