Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: PSDs, PNGs and Transparency

$
0
0
Hi, I'm new to Magick.NET and ImageMagick, and I'm wondering if there is any documentation anywhere for Magick.NET beyond the few simple examples. Specifically I'm trying to figure out how to deal with transparencies. I'm not finding the API very straight forward, and the method signature descriptions in Visual Studio are pretty generic. I've been looking at the ImageMagick documentation, but I'm having trouble relating the command line arguments to Magick.NET APIs (and even the ImageMagick docs seem quite obscure). Or maybe I'm just too much of an IM newb.

Anyway, I'm loading a multi-layer PSD, which I need to turn into 2 PNGs. The first PNG is just the top (last) layer of the PSD, and the second PNG is the full PSD. The issues I'm having is that:

A. On both PNG files, the white area is transparent in the PNG, and the transparent area is white (i.e. the wrong area is transparent). I've tried to correct this, but either I end up with an all black PNG, or an all transparent PNG.

B. On the PNG created from multiple layers, lines that are solid black or red in the PSD appear as transparent, with a faint trace around them. Plus problem "A" above.

This is my code at the moment:

string fileName = image.ImageKey.Substring(0, image.ImageKey.LastIndexOf("."));
            using (MagickImageCollection collection = new MagickImageCollection(image.Image))
            {
                using (MagickImage topLayer = collection[collection.Count - 1])
                {
                    //collection.Remove(topLayer);

                    MagickImageInfo info = new MagickImageInfo(image.Image);

                    topLayer.BackgroundColor = new MagickColor(255,255,255);
                    bool hasAlpha = topLayer.HasAlpha;
                    //topLayer.Alpha(AlphaOption.Background);
                    topLayer.AlphaColor = new MagickColor(255,255,255);
                    //.ColorAlpha(new MagickColor(255, 255, 255));
                    //topLayer.Opaque(new MagickColor(255, 255, 255, 255), new MagickColor(0, 0, 0));
                    //topLayer.Transparent(new MagickColor(255, 255, 255));
                    topLayer.Write(path + fileName + "_toplayer.png");
                }

                collection.Coalesce();
                using (MagickImage bottomLayer = collection[0])
                {
                    bottomLayer.BackgroundColor = MagickColor.Transparent;
                    bottomLayer.Write(path + fileName + "_bottomlayer.png");
                }
            }
Any input is greatly appreciated :)

Thanks,
Mike

Viewing all articles
Browse latest Browse all 3693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>