I am trying to use RMagick to convert SVG to PNG of a different size.
When I read in SVG Magick::Image.read('drawing.svg')and wrote it in drawing.png (equivalent to just starting convert drawing.svg drawing.pngfrom the command line), the size is 744x1052.
Suppose I want PNG to be twice as large as the default. You cannot just read it, resize it, and then write it, because it first rasterizes the SVG and then scales the image twice as much, losing the quality and all the advantages of using vector graphics in the first place. Therefore, instead, if I understand correctly, you should set the image density when reading.
image = Magick::Image.read('drawing.svg'){self.density = 144}.first
But it image.densitystill reports the density as "72x72", and if I exit the image, then it has the same size as before, 744x1052. It does not seem to matter how I indicate density when reading. With 144, 144, 144.0, 144.0, 144 × 144 and 144.0x144.0, "72x72" is always returned.
Starting convert -density 144 drawing.svg drawing.pngfrom the command line works as expected and generates PNG, which is twice as much as before, 2104x1488.
I am using OS X 10.6.7, ImageMagick 6.7.0-0 (installed via MacPorts), RMagick 2.13.1 and Ruby 1.9.2p180. When I put my code in the context of a small Sinatra web application on Heroku, it has the same wrong behavior, so the problem is not related to OS X or MacPorts.