this is my first post and I hope I can find the solution to my problem.
I have an SVG file with a transparent background and I try to compose it with another file (the background).
I use Image.read("file.svg"), then I compose it with the Image background and finally write to a jpeg file.
All is fine except the fact that the svg background becomes "white" when is loaded into the Image object and consequently, the composition results covered by the white background
My question is: how can I import the information about "transparent" background from the input image? The only function I know is Image.read(), but it seems to convert the transparent to white...
This is a my test case, where in the file '01_r.jpg' i cannot view the background.
Code: Select all
#include <Magick++.h>
#include <iostream>
#include <cstring>
using namespace std;
using namespace Magick;
int main(int argc, char **argv)
{
InitializeMagick(*argv);
Image svg;
Image bkg;
try
{
// Read a file into image object
svg.read("r.svg");
//svg.transparent(Color("white")); <-- if I uncomment this, I can view the background, but this is not a solution, because the white is used, not just the background
bkg.read("r-01.bmp");
bkg.composite(svg, 0, 0, CompositeOperator::OverCompositeOp);
bkg.quality(80);
// Write the image to a file
bkg.write("01_r.jpg");
}
catch (Exception &error_)
{
cout << "Caught exception: " << error_.what() << endl;
return 1;
}
return 0;
}