5

Sorry if the title didn't make any sense.

Currently, the following parameters on the imagemagick convert utility are perfect for what I need. I'm tring to take an .svg file, make it larger and write it as a png file.

 convert -density 36  home.svg  home_1.png

Unfortunately, I need to be using Magick++ (the C++ Interface/API for ImageMagick), but I can't seem to get the equivalent operation in Magick++.

Are there any ImageMagick pros that would be able to help me out on this?

My current code is:

image.density(Geometry(36,36));

    image.read( "Character.svg" );

    image.write( "xx.png" ); 

I've tried moving the image.density() part around, but my image is never changes. It's simply rasterized and saved as a png.

Andrea
  • 11,801
  • 17
  • 65
  • 72
Brad
  • 10,015
  • 17
  • 54
  • 77

1 Answers1

2

I'm no ImageMagick pro, but when I tried this code:

#include <Magick++.h>

int main(int argc, char **argv) {
  Magick::Image img;
  img.density(Magick::Geometry(36,36));
  img.read(argv[1]);
  img.write(argv[2]);

  img.density(Magick::Geometry(72,72));
  img.read(argv[1]);
  img.write(argv[3]);
}

with this SVG file, e.g.:

$ ./resize example.svg out_small.png out_large.png

...the file out_small.png was 300x300 pixels, whereas out_large.png was 600x600 pixels.

This was on Windows 7 via cygwin.

Nate Kohl
  • 35,264
  • 10
  • 43
  • 55
  • Wow that's interesting. When I try almost the same code on environment, it doesn't work. Using the same SVG example you used, both mine output to 600x600 pixels. I'm using MSVC, so maybe it's bugged? – Brad Nov 15 '10 at 03:16
  • Sure, it's possible MSVC has some issues with this. I'd be curious if this works for you with other input/output file formats, or if any of the image modifiers work. – Nate Kohl Nov 15 '10 at 03:34
  • I've tried some other modifiers like zoom() and it seems to work so I think MSVC is just having issues with the SVG/density stuff. – Brad Nov 15 '10 at 04:35