ImageMagick “convert” utility Magick++ equivalent?

 ̄綄美尐妖づ 提交于 2019-12-10 16:53:59

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/4180916/imagemagick-convert-utility-magick-equivalent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!