I'me trying to use ImageMagick to convert SVG files to PNG.
The SVG file is as follows:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
<image xlink:href="picture.jpg" width="200" height="200"/>
</svg>
No matter what method I use the final result doesn't include the image. Other SVG elements have rendered correctly.
I've tried:
convert test.svg test.png
rsvg-convert -o test.png test.svg
I've tried changing the image path to use file:///, absolute paths, remote urls, and url encoded variations of each. I've also formatted my file with and without a doctype.
I'm using librsvg 2.36.3 and ImageMagick 6.8.0-10
I have been able to use phantomjs to convert them but it seems like overkill for this one task.
Please help!
For me, installing gtk3 (or probably more specifically "shared-mime-info" helped. (and re-installing rsvg afterwards AND using absolute "file:///" uri for href AND having image file in same directory as svg file)
More info (I'm still confused what exactly is going on):
I think the problem is not with rsvg directly, but with gdk-pixbuf(2) library
I found the place in the code where gdk-pixbuf is used to load the image. I confirmed (using printf debuggin) that it doesn't throw an error (seems to load pixbuf just fine) even if the uri in the href does not point to a file.
the gtk3 dependency should only be necessary for rsvg-view-3 tool, not for rsvg, but it seems to be (or one of the dependencies that got pulled in when I installed gtk3)
It still works even after uninstalling gtk3. It even still works after uninstalling gtk3, then rebuilding rsvg (./configure detects: "gtk3: no"), so I figure it must have to do with one of the dependencies that got pulled when I installed gtk3:
atk-2.10.0-1-i686
hicolor-icon-theme-0.12-2-any
gtk-update-icon-cache-2.24.22-1-i686
libtasn1-3.3-2-i686
p11-kit-0.20.1-1-i686
gnutls-3.2.5-1-i686
libcups-1.7.0-1-i686
libxinerama-1.1.3-2-i686
shared-mime-info-1.2-1-i686
libgusb-0.1.6-1-i686
nspr-4.10.1-2-i686
js-17.0.0-1-i686
polkit-0.112-1-i686
shared-color-profiles-0.1.5-1-any
dconf-0.18.0-1-i686
colord-1.0.2-2-i686
recordproto-1.14.2-1-any
libxtst-1.2.2-1-i686
at-spi2-core-2.10.1-1-i686
at-spi2-atk-2.10.0-1-i686
xkeyboard-config-2.10.1-1-any
libxkbcommon-0.3.1-1-i686
(I'm leaving these here in case it's not the lib I identified in the end)
So I tried removing these deps in groups and rebuilding and testing in between. Turns out the one making it work is...
* shared-mime-info
Related
I wonder how can we convert SVG to DXF in Inkscape CLI mode. IN GUI to export/save svg to dxf we can do it from file menu by doing Save As
i went through inkscape cli document : https://inkscape.org/doc/inkscape-man.html
here mostly export words is used , so i tried
inkscape --export-type=out.dxf in.svg
inkscape --export-filename=out.dxf in.svg
but no success giving me errpr
InkFileExportCmd::export: Unknown export type: out.dxf. Allowed values: [svg,png,ps,eps,pdf,emf,wmf,xaml].
however in GUI under FILE -> SAVE AS we can see a lot of file formats including DXF
You need to run the extension from the command line, using the available parameters. Find it in your Inkscape installation folder, inside the directory /share/inkscape/extensions.
So, in the most basic version:
python3 dxf_outlines.py --output="yourfile.dxf" "yourfile.svg"
You can also type
python3 dxf_outlines.py -h
to find out all about the options.
I tried using sample code:
// command:
C:\>F:\inkscape\bin\inkscape --export-filename=F:\aaa.dxf F:\valve.svg
Although there was no tracing back messages, but it succeeded:
I'm trying to convert DXF files (from Fusion360) to plain SVG files using the Inkscape CLI. It works fine with one small annoyance: the Inkscape GUI promps me on how to read the dxf file (the settings in there are fine, all I do is click ok).
It's the same dialog you get when importing a dxf file through the Gui.
The command I'm running:
/Applications/Inkscape.app/Contents/Resources/bin/inkscape -z -l <absolutePath>/output.svg <absolutePath>/input.dxf
I've also tried this with no success with regard to the dialog popup:
/Applications/Inkscape.app/Contents/Resources/bin/inkscape -z -f <absolutePath>/input.dxf -l <absolutePath>/output.svg
-z means no GUI. Which works in terms of no Inkscape instance starting (XQuartz is starting though), but the pesky dialog can just assume ok and move on rather than checking with me for an ok click.
To be clear, the actual export is just fine. It's only the Gui dialog that's crashing my CLI-high :)
In short: any chance on flagging that dialog to go ahead without actual interaction from my part?
Specs:
MacOS 10.13.
Inkscape 0.91
In reality, I detected the original problem when using Inkscape 0.91 - it has an option to render Latex images on an SVG surface. Digging a little, it seems that the problem is due to pstoedit failing, which, when called separately reports:
$ pstoedit -f svg test.ps test.svg
pstoedit: version 3.70 / DLL interface 108 (built: Sep 25 2017 - release build - g++ 4.9.3 - 64-bit) : Copyright (C) 1993 - 2014 Wolfgang Glunz
Unsupported output format svg
Digging still deeper, it seems that pstoedit uses plotutils to do the work, but, from tests, plotutils seems to do what it is supposed to do:
echo 0 0 1 1 2 0 | spline | graph > test.meta
succesfully creates a test.meta file with a spline in it, while
plot -T svg test.meta > test.svg
converts that metafile correctly to test.svg
Versions installed are:
plotutls 2.6 (seems Ok, creates svg)
pstoedit 3.7 (works, except for svg)
Inkscape 0.91 (Latex appears in the extensions | render menu
but doesn't work - because pstoedit doesn't generate
the required svg)
I've also reviewed the ./configure options to check if something was missing - no luck.
Distribution is Slackware64-current. As Slackware always installs the header files, no header files (-dev, -devel...) are missing here (I've checked too. And recompiled pstoedit after installing plotutils)
Digging even deeper, I found the reason for the problem. Slackware64 installs libraries to /usr/lib64, so the the pstoedit plugins were installed in /usr/lib64/pstoedit. But it seems that pstoedit does NOT look in that directory when trying to load the plugins at runtime - it looks for /usr/lib/pstoedit instead.
It then reports supporting several formats except svg - giving the impression it did find some plugins. In a Debian bug report I found that the reporter checked the plugin search using the -verbose command line option, which doesn't exit (it's just -v)
Anyway, I solved the issue (for the moment) by making a symlink from /usr/lib/pstoedit to /usr/lib64/pstoedit. I'll send a report to the program author too.
Hello fellow Stackers,
Currently I am working on a website which requires the ability to handle, manipulate, create and save PostScript encoded files. Research on the topic pointed me towards two PHP classes called Imagick and MagickWand – both of which use Image Magick, which in turn depends on Ghostscript. Unfortunately the GD PHP class is not up to the task.
I am performing the installation processes on a server running GNU/Linux via SSH from my Mac with OS X 10.9.1. Any help would be much appreciated. If any other details are needed, please inform me and I will do my absolute best to provide them.
Thus far, I have managed to make Image Magick and Ghostscript function independently – while simultaneously installed on the same system. However I was not able to install Ghostscript accordingly for it to function as an Image Magick delegate. From Terminal I was able to run the convert and gs commands successfully. At the time I was able to use the Imagick PHP class to perform the required tasks – such as detecting Color Space – on rasterised images.
As it stands Image Magick has been uninstalled from the server. I was not able to uninstall Ghostscript correctly. So my first question is: how on earth do I uninstall Ghostscript 9.10? It seems Ghostscript does not include an uninstall in its Makefile, ie: make uninstall returns make: *** No rule to make target 'uninstall'. Stop..
I have done some research and it seems that I should have compiled the Ghostscript shared library first: http://www.linuxfromscratch.org/blfs/view/svn/pst/gs.html
Naturally I attempted to perform the steps in the article on Linux from Scratch. I have removed expat, freetype, lcms2, jpeg and libpng. I have performed ./configure with the suggested commands. I have also performed make and make so, both of which fail and exit, returning:
pngrutil.c:(.text+0x3cb): undefined reference to 'inflateReset2'
collect2: ld returned 1 exit status
make: *** [bin/gs] Error 1.
edit: I have since narrowed this down to be related to Zlib.
I am looking for either an alternative to Imagick and MagickWand (which I was not able to find), insights into what is going wrong during the installation process or what might be done to resolve the current error.
Thank you all in advance.
A manual process to uninstall may be required if there is no uninstall defined for the makefile.
This has been discussed in the question What's the opposite of 'make install', ie. how do you uninstall a library in Linux?.
I ditched the idea of using Ghostscript as an Image Magick Delegate, not only because the installation process was not working out for but, but also due to the fact that my research taught me that Image Magick rasterises all input files.
Instead I used the PHP exec() function to directly execute Ghostscript.
I have a node app which accepts an uploaded image (using formidable) and stores it into an Amazon S3 bucket. Before it is saved to S3, I want to get the image's width, height, etc. for future consideration. I found this question which helped: Opening images on NodeJS and finding out width/height
However, when I try to open the image with imagemagick (or gm, for that matter, I've tried both) I get error 127. Specifically, imagemagick reports:
{"timedOut":false,"killed":false,"code":127,"signal":null}
I know the file exists (because it is properly uploaded to the S3 bucket), and I can manipulate it (eg, rename) via fs, but I cannot find any documentation on error code 127 to determine why IM fails. Thinking that perhaps there was something odd about the file uploaded to formidable causing it to not be read properly, I tried using imagemagick to load a simple "test.jpg" image in the same folder:
im.identify('test.jpg', function(err, features){
if(!err)
{
// my image processing code
}
else
{
// my err handling code; spits out the error above
}
});
Unfortunately, this fails in the exact same manner, even though I'm sure test.jpg is a good and properly formatted image.
So, can anybody help me understand what error 127 is and why ImageMagick would throw it when fs is able to read the file just fine...?
These are a couple of php commands to find the path to Imagemagick which should confirm it is installed.
Sometimes in php there is a problem just using convert and you need to use the full path; something like /usr/local/bin/convert
echo "<pre>";
system("type convert");
system('which convert',$path); print_r($path);
echo "</pre>";
I know you are not using php but you should still be able to use the methods.
Make sure "convert" is installed
sudo apt-get update
sudo apt-get install imagemagick --fix-missing
Derp. I didn't have ImageMagick itself installed. I assumed that the NPM installation was all that was required; did not realize there were additional dependencies, and the error message was a bit cryptic ;)
I had the same problem, just install Graphics Magick, http://www.graphicsmagick.org/
test if your intallation works as the wizard suggest and that's it.