Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inkscape conversion command deprecated for Inkscape 1.2.2 (2022-12-09) #47

Open
CodeMazeSolver opened this issue Jan 23, 2023 · 5 comments

Comments

@CodeMazeSolver
Copy link

Hello,
I tried to use the \includesvg{} command in Latex (pdfLatex). The creation of the document fails.
My Inkscape version is Inkscape 1.2.2 (732a01da63, 2022-12-09)

Concretely, I use: \includesvg{./path/to/my}
for the conversion from .svg to .png. The following command is executed and appears in the log file:

runsystem(inkscape "./path/to/my.svg" -D --export-dpi=300 --export-filename= "my_svg-raw.png")

I tried running this command in my console. It does not work there as well. After some research, I found out that there is a new syntax.
This command works in the console.

inkscape --export-type="png" --export-filename= ".\path\to\my.svg"

However, how can I change the commands that are used in the package?

I tried the inkscapeopt option, but it just adds an additional switch and does not change the main command.

Hopefully, this is easy to fix. For now, I just switch to creating the .png files by hand and use \includeinkscape{} to add them to my Latex file.

Best regards,
CMS

@Andonome
Copy link

Andonome commented Jan 23, 2023 via email

@mrpiggi
Copy link
Owner

mrpiggi commented Jan 23, 2023

The CLI of Inkscape was dicussed some time ago (#20). At this time --export-type was dropped completely. Apparently, it was brought back again. Nevertheless, inkscape --help as well as Inkscape man page both state (if --export-type is omitted)

file type is guessed from extension if present
the file type to export will be inferred from the extension of the specified filename

What do you get, typing inkscape -V on your terminal? Maybe the link in PATH is pointing to another installation? With

svg.sty    2020/11/26 v2.02k (include SVG pictures)
Inkscape 1.2.2 (732a01da63, 2022-12-09)

calling inkscape "my-svg-example.svg" -D --export-dpi=300 --export-filename="my-svg-example_svg-raw.png" works exactly as expected and creates the desired png file.

\begin{filecontents}[noheader]{my-svg-example.svg}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg">
  <g>
  <text>Package svg: \LaTeX</text>
  </g>
</svg>
\end{filecontents}

\listfiles
\documentclass{article}
\usepackage{svg}
\begin{document}
\includesvg[inkscapeformat=png]{my-svg-example.svg}
\end{document}

my-svg-example_svg-raw

@CodeMazeSolver
Copy link
Author

Thanks for your fast replies.

> inkscape -V
This is what I get, the same version I wrote earlier.
Inkscape 1.2.2 (732a01da63, 2022-12-09)

I made some changes yesterday as well. Right now I have this as my path variable:
C:\Program Files\Inkscape\bin

In the log, I now find that it does not recognize Inkscape even though it is found using cmd.

(|'inkscape' -V )

Package svg Warning: No version of Inkscape was detected by invoking
(svg)                `inkscape -V'
(svg)                so the Inkscape export will fail quite sure as the
(svg)                command is probably unknown to your OS. You could set
(svg)                `inkscapeversion=<version>' manually but this is very
(svg)                unlikely to work on input line 172.

and then

Package svg Info: Calling Inkscape on input line 244.
runsystem(inkscape "./svg/my.svg" -D --export-dpi=300 --export-filename="my_svg
-raw.png")...executed.

runsystem(inkscape "./svg/my.svg" -D --export-dpi=300 \relax --without-gui --ex
port-png="my_svg-raw.png")...executed.

as well as

Package svg Error: Inkscape version not dete
cted.

See the svg package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.244 \includesvg{./svg/my}
                           
It was tried to invoke `inkscape'
for file "./svg/my.svg"
but no result was produced. Check the log file
and set `inkscapeversion=<version>' manually.

runsystem(inkscape "./svg/my.svg" -D --export-dpi=300 --export-filename="my_svg
-raw.png")...executed.


Package svg Warning: The export with Inkscape failed for file
(svg)                `./svg/my.svg'
(svg)                Troubleshooting: Please check in the log file how
(svg)                the invocation of Inkscape took place and try to
(svg)                execute it yourself in the terminal on input line 244.

I guess I now have an issue with the Inkscape installation...

I did a fresh installation, loading the newest version again from the web to make sure I don't have a corrupted installer.
Also, I still use the same path for the system variables Path.
C:\Program Files\Inkscape\bin

Running the command
inkscape "./svg/my.svg" -D --export-dpi=300 --export-filename="./svg/my-svg.png"

Again, it works in cmd and not in Latex...

Using the actual command as logged in the log file:

inkscape "./svg/my.svg" -D --export-dpi=300 --export-filename="my_svg-raw.png"

The file is successfully created using the console, but not when running it via pdfLatex.
However, the file is not created in the source file folder svg but rather in the folder, which the command is executed from. Might this be an issue?

@mrpiggi
Copy link
Owner

mrpiggi commented Jan 24, 2023

That's a tricky one. Package svg tries to detect the version of Inkscape by parsing the output of inkscape -V. In order to get this from stdout it needs to invoke \@@input|"'inkscape' -V " and this might be an problem. So maybe setting \svgsetup{inkscapeversion=1} in the preamble would help. Another solution could be to set the absolute path to Inkscape with \svgsetup{inkscapeexe="C:\Program Files\Inkscape\bin\inkscape.exe"} (try both variants with or without quotes).

However, the file is not created in the source file folder svg but rather in the folder, which the command is executed from.

Package svg creates the desired file in the root folder of your tex file and moves it to the destination folder afterwards for several reasons. Mainly because on some systems, you can't run the inkscape export right in the desired output folder due to write restrictions. So this isn't the problem.

@CodeMazeSolver
Copy link
Author

CodeMazeSolver commented Jan 24, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants