问题
I am on a Mac using Mac OS X 10.5, and I am trying to use ImageMagick to convert an SVG file to a PNG. The problem is when I use it the rotated image doesn't show up in the correct position. If I use Batik to convert the file, it works properly.
After doing some research I found a thread that talked about trying to upgrade the SVG library. Currently, I am using ImageMagick 6.6.5 and the SVG library is 2.7.7 according to "identify -list format". The thread I found recommended using librsvg 2.32.
I have tried using port to install the updated SVG library and using port to reinstall ImageMagick. The problem and the question I have is no matter what I do with port I can't get it to use the newer version of the SVG library. It stays at 2.7.7. How do I get it to use the new library?
回答1:
Unfortunately, I went down this path for a while too. After a very long time beating my head against the wall and getting fairly bruised in the process, I found the only thing that worked was inkscape
. Everything else just doesn't pull it off. Unfortunately, inkscape
's CLI interfaces aren't great and don't offer you nearly as much flexibility as you'd like (especially when converting to PDFs, etc), it does at least work better than everything else. To use it:
inkscape -f INPUT.SVG -e OUTPUT.PNG
See inkscape --help
for aditional details.
Extra word of warning: inkscape -h
actually doesn't do what you want for help and launches the GUI.
回答2:
I was experiencing this on 10.7, having installed imageMagick via macPorts. After trying and failing a couple of uninstall/reinstalls with differing options. I finally uninstalled and built from source, after installing librsvg, and now everything works using the updated svg libraries.
ImageMagick's unix source and instructions are here: http://www.imagemagick.org/script/install-source.php
ImageMagick also provides instructions on linking libraries and library paths explicitly in your configuration step (http://www.imagemagick.org/script/advanced-unix-installation.php) although I didn't have to do this.
来源:https://stackoverflow.com/questions/6068751/svg-converting-using-imagemagick-doesnt-apply-a-translation-correctly