This project has moved. For the latest updates, please go here.

Simple Composite producing image that looks "inverted"

Mar 6, 2015 at 7:53 PM
This should be simple enough, I thought. I really didn't change much from the code I was working with yesterday.

The two images are writing out. The background image looks fine. But the image on top looks like a negative

Image
using (MagickImageCollection images = new MagickImageCollection())
                    {
                        string appPath = Path.GetDirectoryName(Application.ExecutablePath);
                            
                        //add the bg image
                        MagickImage background = new MagickImage(Path.Combine(appPath, "background-V.jpg"));
                        images.Add(background);

                        //add the customer's image
                        MagickImage image = new MagickImage(newFile);
                        image.Border(10);
                        image.BorderColor = Color.White;
                        images.Add(image);


                        //do the composite and write over the image
                        background.Composite(image, Gravity.Center, CompositeOperator.Over);
                        string outputDir = @"c:\workspace\HFPoutput";
                            if (!Directory.Exists(outputDir))
                            {
                                Directory.CreateDirectory(outputDir);
                            }
                        background.Write(Path.Combine(outputDir, Path.GetFileName(newFile)));
Coordinator
Mar 6, 2015 at 7:57 PM
Can you add a link to the images you are using?
Mar 6, 2015 at 8:02 PM
Coordinator
Mar 6, 2015 at 8:11 PM
I was already suspecting this, one of your images is a CMYK jpeg instead of RGB. You will get this result if you mix images that have a different color space. You should probably set the ColorSpace of your background image to sRGB. And if your input can also be CMYK you might also want to change that to sRGB.