I'm using Magick++ to render a SVG image to PNG with the code shown below. Image_t* is just an alias for Magick::Image. svg_str contains the SVG's XML stores as a string, and size is the desired output size. This code works on a regular PC, but when I go mobile (ios) it crashes.
I've narrowed down the problem to a point I can't proceed. The crash is due to magick being unable to read a temporary file. My explanation is the following, to convert to SVG, the read method first saves a temporary, invokes some sort of command line executable (via system call) and then tries to read the output of that command. Thus, as the writing succeeds there is no "write exception", but only a "read exception", because the system call failed. For example, you can't call "convert" in iOS.
BTW, I'm pretty sure it is not a path problem because I'm setting MAGICK_TMPDIR and MAGICK_TEMPORARY_PATH to writable places in the device, and I'm able to see some tmp files there.
So, my questions are the following:
1) Can you confirm my guess that some tmp writing is going on?
2) If affirmative, is there any way to avoid it for SVG->PNG rendering?
3) How can I debug this in a deeper way?
Thanks in advance.
Best,
Juan
Code: Select all
Image_t* MaskGenerator::createWithSvg(std::string svg_str, Magick::Geometry size)
{
Image_t *svg_image = gstNew Image_t();
svg_image->backgroundColor(Magick::Color(0x0, 0x0, 0x0, QuantumRange));
Geometry density = Geometry(500, 500);
svg_image->resolutionUnits(PixelsPerInchResolution);
svg_image->density(density);
Magick::Blob svg_blob(svg_str.c_str(), svg_str.length());
svg_image->magick("SVG");
try{
svg_image->read(fname_tmp);
}catch(Magick::Warning &w)
{
xml_out("Magick Warning in read SVG blob\n");
xml_out("%s",w.what());
}
svg_image->resize(size);
return svg_image;
}