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

Picture Heap Issues

May 3, 2016 at 4:33 PM

I am trying to produce what looks like a heap of photos. I found this as a starting point: - a php example -
but I want to drive it from a code loop, using random position and rotate.

My code is below:
       using (MagickImage image = new MagickImage(new MagickColor("blue"), 3000, 3000))
            var rand = new Random();
            var rand2 = new Random();
            var files = Directory.GetFiles("g:\\picsin", "*.jpg");
            for (int i = 1; i < 5; i++)
                string infile = files[rand.Next(files.Length)];
                using (MagickImage image2 = new MagickImage(infile))
                    image2.Settings.BorderColor = new MagickColor("red");
                    image2.Rotate(rand2.Next(-25, 25));
                    image2.BackgroundColor = new MagickColor("transparent"); //doesn't help
                    image.Composite(image2, rand2.Next(100, 2500), rand2.Next(100, 2500));
The result is at

1) When I angle the pictures with rotate I get a white bounding box that I do not want
2) I set the border and border color - the border is there (light grey), but I expect it to be red here
3) I would like to make most of the pictures nearly transparent, so the top few stand out - these will eventually be positioned carefully so as not to overlap. I can't find a way to do this.
4) I also notice image degradation - does that come from running Composite in a loop, and is there a better way to do it all at once? I found an example here that uses MIFF:- - can that be done here and would it help?

Thanks for Magick.NET and for any help.

May 5, 2016 at 6:34 PM
Try add:
image2.VirtualPixelMethod = VirtualPixelMethod.Transparent;
image2.Rotate(rand2.Next(-25, 25));