2
$\begingroup$

I wrote a little script to convert various graphics files (.ps, .eps, .pdf) to the raster ones (.png). Export[out, Import[in], ImageSize -> size] fails for some files without any message at an import step: Import[in] === $Failed (well, there’s another issue, something wrong with input files, maybe?). Albeit, Inkscape does the work well via inkscape $in -w $size -e $out -z. The problem is: Mathematica’s Run doesn’t like Inkscape.

In[]:= Run["inkscape -z file.ps"]
(*
Emergency save activated!
Emergency save completed. Inkscape will close now.
If you can reproduce this crash, please file a bug at www.inkscape.org
with a detailed description of the steps leading to the crash, so we can fix it.
** Message: Error: Inkscape encountered an internal error and will close now.
*)
Out[]= 139

I tried in a notebook, in a shell mode, in a Mathematica‌Script. Other GUI programs Run properly. A PHP equivalent I had to write

passthru("inkscape $in -w $size -e $out -z")

works well, as do bare bash.

What is this hatred between Inkscape and Mathematica? Can you reproduce this behaviour? Mathematica 9 at Scientific Linux is used.

$\endgroup$
  • $\begingroup$ Try to use convert from ImageMagick or upgrade to version 10 (if your license allows) and try this. $\endgroup$ – Szabolcs Jul 16 '14 at 15:30
  • $\begingroup$ @Szabolcs, I’m going to upgrade as soon as possible. So, in 10 it is solved, isn’t it? (Can’t wait!) Thanks for proposing ImageMagick, great. But what if I want to deal with vectors? $\endgroup$ – McSaks Jul 16 '14 at 15:39
  • $\begingroup$ Sorry, I should have said it clearly that I did not test this. I do not have inkscape installed and I do not use Linux. It is my suspicion that it might work with this new functionality, but I do not know this for certain. I might be wrong. $\endgroup$ – Szabolcs Jul 16 '14 at 15:41
  • $\begingroup$ I know for example that when using the front end, Run["python"] exits immediately, probably because there's no stdin. But StartProcess["python"] lets python keep running until it is explicitly shut down. I'm on OS X, so similar to Linux. $\endgroup$ – Szabolcs Jul 16 '14 at 15:44
  • $\begingroup$ @Szabolcs, Run["python"] works in terminal. Run["inkscape"] or Run["inkscape -z file"] does not. Run["inkscape -z"] works but only prints ‘Nothing to do!’, not very useful. That’s weird… $\endgroup$ – McSaks Jul 16 '14 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.