Skip to content

Instantly share code, notes, and snippets.

@sawa2d2
Last active November 29, 2019 04:12
Show Gist options
  • Select an option

  • Save sawa2d2/6402e70efeac3824033a5420515cc079 to your computer and use it in GitHub Desktop.

Select an option

Save sawa2d2/6402e70efeac3824033a5420515cc079 to your computer and use it in GitHub Desktop.
vector-image-convertor
FROM debian:stretch
SHELL ["/bin/bash", "-c"]
RUN apt-get update \
&& apt-get install -y wget gcc make inkscape \
&& wget https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs927/ghostscript-9.27.tar.gz \
&& cd ghostscript-9.27 \
&& ./configure --disable-fileinfo \
&& make -j1 \
&& su \
&& make install
# && apt install -y texlive-font-utils # FOR epstopsd AND eps2epsi (https://packages.debian.org/stretch/tex/texlive-font-utils)
# COPY vector-image-convertor.sh /
# ENTRYPOINT ["/vector-image-convertor.sh"]
SVG=$(echo $1)
FILENAME=$(echo "$SVG" | sed 's/\.[^\.]*$//')
cairosvg "$SVG" -o "${FILENAME}.pdf" # SVG to PDF
pdf2ps "${FILENAME}.pdf" "${FILENAME}.eps" # PDF to EPS
inkscape "${FILENAME}.pdf" -M "${FILENAME}.emf" # PDF to EMF
rm "${FILENAME}.pdf"
# Converts all svg files in the directory to eps and emf.
# Usage: $ sh svg2epsANDemfALL.sh DIRNAME
\find $1 -name \*.svg | xargs -n 1 sh svg2epsANDemf.sh
for %%f in (%*) do (
ps2epsi %%f %%~pf%%~nf.eps
epstopdf %%~pf%%~nf.eps %%~pf%%~nf.pdf
pdftocairo -svg %%~pf%%~nf.pdf
"C:\Program Files\Inkscape\inkscape.com" -z -f %%~pf%%~nf.svg -M %%~pf%%~nf.emf
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment