Michael Anderson schrieb:
I'm trying to implement the instructions provided on the wiki site for
using inkscape to handle svg figures. I can't seem to get it to work
with Lyx 1.5. I have a feeling there is a little trick or two that I am
missing. Does someone have a verbose set of instructions on how to
implement inkscape, or how to use imagemagik in a similar fashion?
Hello,
i use the following:
1) the two attached python scripts in the users .\script directory
2) in the preferences file add:
#
# MISC SECTION ######################################
#
\path_prefix "<old path>;<path to Inkscape>"
#
# FORMATS SECTION ##########################
#
\format "svg" "svg" "Scalable Vector Graphics" "" "" "inkscape" "vector"
#
# CONVERTERS SECTION ##########################
#
\converter "svg" "eps" "python -tt $$s/scripts/svg2eps.py $$i $$o" ""
\converter "svg" "png" "python -tt $$s/scripts/svg2png.py $$i $$o" ""
3) reconfigure
Bernhard
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
# file svg2png.py
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.
#
# \author Bernhard Roider
# This script converts an svg file to a png file
# Usage:
# python svg2png.py ${base}.svg ${base}.png
# This command generates
# ${base}.png for the lyx preview.
#
import os, sys
# We expect two args, the names of the input and output files.
if len(sys.argv) != 3:
sys.exit(1)
input = os.path.abspath(sys.argv[1])
output = os.path.abspath(sys.argv[2])
# Fail silently if the file doesn't exist
if not os.path.isfile(input):
sys.exit(0)
# Convert using inkscape
if os.system('inkscape --export-png="%s" --export-area-drawing
--export-area-snap --file="%s"' % (output, input)) != 0:
print 'inkscape png conversion fails'
sys.exit(1)
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
# file svg2eps.py
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.
#
# \author Bernhard Roider
# This script converts an svg file to an eps file
# Usage:
# python svg2eps.py ${base}.svg ${base}.eps
# This command generates
# ${base}.eps for the lyx preview.
#
import os, sys
# We expect two args, the names of the input and output files.
if len(sys.argv) != 3:
sys.exit(1)
input = os.path.abspath(sys.argv[1])
output = os.path.abspath(sys.argv[2])
# Fail silently if the file doesn't exist
if not os.path.isfile(input):
sys.exit(0)
# Convert using inkscape
if os.system('inkscape --without-gui --export-eps="%s" --file="%s"' % (output,
input)) != 0:
print 'inkscape eps conversion fails'
sys.exit(1)