示例#1
0
 public void CoverArtWand3DTests()
 {
     using (var wand = new MagickWand(TestImageFolder1))
     {
         var t = wand.CloneMagickWand();
         t.CurrentImage.ShearImage(new PixelWand(ColorHEX.None, 1), 0, 10);
         t.CurrentImage.ExtentImage(t.CurrentImage.Width + 50, t.CurrentImage.Height + 50, -25, -25);
         //RaiseImage
         //wand.CurrentImage.ShadeImage(true, 5, 6);
         //
         wand.CurrentImage.TrimImage(100);
         t.SaveImage(Path.Combine(SaveDirectory, "logo_extent.png"));
     }
 }
示例#2
0
 public void CoverArtWandShadowTests()
 {
     using (var wand = new MagickWand(TestImageFolder1))
     {
         using (MagickWand nailclone = wand.CloneMagickWand())
             using (var blackPixelWand = new PixelWand(ColorName.Black))
             {
                 nailclone.CurrentImage.BackgroundColor = blackPixelWand;
                 nailclone.CurrentImage.ShadowImage(80, 5, 5, 5);
                 nailclone.CurrentImage.CompositeImage(wand, CompositeOperator.CopyCompositeOp, 0, 0);
                 nailclone.SaveImage(Path.Combine(SaveDirectory, "logo_extent.png"));
             }
     }
 }
 public void CoverArtWandShadowTests()
 {
     using (var wand = new MagickWand(TestImageFolder1))
     {
         using (MagickWand nailclone = wand.CloneMagickWand())
         using (var blackPixelWand = new PixelWand(ColorName.Black))
         {
             nailclone.CurrentImage.BackgroundColor = blackPixelWand;
             nailclone.CurrentImage.ShadowImage(80, 5, 5, 5);
             nailclone.CurrentImage.CompositeImage(wand, CompositeOperator.CopyCompositeOp, 0, 0);
             nailclone.SaveImage(Path.Combine(SaveDirectory, "logo_extent.png"));
         }
     }
 }
        public void CoverArtWand3DTests()
        {
            using (var wand = new MagickWand(TestImageFolder1))
            {
                var t = wand.CloneMagickWand();
                t.CurrentImage.ShearImage(new PixelWand(ColorHEX.None, 1), 0, 10);
                t.CurrentImage.ExtentImage(t.CurrentImage.Width + 50, t.CurrentImage.Height + 50, -25, -25);
                //RaiseImage
                //wand.CurrentImage.ShadeImage(true, 5, 6);
                //
                wand.CurrentImage.TrimImage(100);
                t.SaveImage(Path.Combine(SaveDirectory, "logo_extent.png"));

            }
        }
        public void MediaBrowserThumbnailImageTest()
        {
            using (var wand = new MagickWand(TestImageBackdrop))
            {
                var w = wand.CurrentImage.Width;
                var h = wand.CurrentImage.Height;

                using (var mwr = wand.CloneMagickWand())
                {
                    var newW = 1280;
                    var newH = 720;
                    mwr.CurrentImage.MagickThumbnailImage(newW, newH, true, false);
                    mwr.CurrentImage.StripImage();
                    mwr.SaveImage(Path.Combine(SaveDirectory, Guid.NewGuid().ToString() + ".jpg"));
                }
            }
        }
        public void MediaBrowserResizeImageTest()
        {
            using (var wand = new MagickWand(TestImageBackdrop))
            {
                var w = wand.CurrentImage.Width;
                var h = wand.CurrentImage.Height;

                using (var mwr = wand.CloneMagickWand())
                {
                    var newW = 1280;
                    var newH = 720;
                    mwr.CurrentImage.ResizeImage(newW, newH);
                    mwr.CurrentImage.StripImage();
                    mwr.SaveImage(Path.Combine(SaveDirectory, Guid.NewGuid().ToString() + ".jpg"));
                }
            }
        }
        public void MediaBrowserResizePerformanceImageTest()
        {
            for (var i = 0; i < 100; i++)
            {
                using (var wand = new MagickWand(TestImageBackdrop))
                {
                    var w = wand.CurrentImage.Width;
                    var h = wand.CurrentImage.Height;

                    using (var mwr = wand.CloneMagickWand())
                    {
                        var newW = 1280;
                        var newH = 720;
                        mwr.CurrentImage.ResizeImage(newW, newH, FilterTypes.CatromFilter);
                        mwr.SaveImage(Path.Combine(SaveDirectory, Guid.NewGuid().ToString() + ".jpg"));
                    }
                }
            }
        }
        public void MediaBrowserCollectionImageTest()
        {
            using (var wand = new MagickWand(TestImageBackdrop))
            {
                var w = wand.CurrentImage.Width;
                var h = wand.CurrentImage.Height;

                wand.CurrentImage.AlphaChannel = AlphaChannelType.DeactivateAlphaChannel;
                using (var mwr = wand.CloneMagickWand())
                {
                    mwr.CurrentImage.ResizeImage(w, h / 2, FilterTypes.LanczosFilter, 1);
                    using (var mwg = new MagickWand(w, h / 2))
                    {
                        mwg.OpenImage(TestImageBackdrop);
                        mwr.CurrentImage.CompositeImage(mwg, CompositeOperator.CopyOpacityCompositeOp, 0, 0);
                        wand.AddImage(mwr);
                        var t = wand.AppendImages(true);
                        t.SaveImage(Path.Combine(SaveDirectory, Guid.NewGuid().ToString() + ".jpg"));
                    }
                }
            }
        }
        public void MediaBrowserCollectionImageTest()
        {
            using (var wand = new MagickWand(TestImageBackdrop))
            {
                var w = wand.CurrentImage.Width;
                var h = wand.CurrentImage.Height;

                wand.CurrentImage.AlphaChannel = AlphaChannelType.DeactivateAlphaChannel;
                using (var mwr = wand.CloneMagickWand())
                {
                    mwr.CurrentImage.ResizeImage(w, h / 2, FilterTypes.LanczosFilter, 1);
                    using (var mwg = new MagickWand(w, h / 2))
                    {
                        mwg.OpenImage(TestImageBackdrop);
                        mwr.CurrentImage.CompositeImage(mwg, CompositeOperator.CopyOpacityCompositeOp, 0, 0);
                        wand.AddImage(mwr);
                        var t = wand.AppendImages(true);
                        t.SaveImage(Path.Combine(SaveDirectory, Guid.NewGuid().ToString() + ".jpg"));
                    }
                }
            }
        }
        protected async Task <MagickWand> EnhanceImageAsyncInternal(IHasImages item, MagickWand originalImage, ImageType imageType, int imageIndex)
        {
            Logger.Debug("SoundCloudOverlayEnhancer will treat {0}", new object[] { item.PrimaryImagePath });

            Point point = new Point(0, 0);

            var folderItem = item as Folder;

            if (imageType != ImageType.Primary || folderItem == null || folderItem.SourceType != SourceType.Channel)
            {
                return(null);
            }

            var overlayType = GetOverlayFromFolderId(folderItem.ExternalId);

            string str = Plugin.Instance.GetExtractedResourceFilePath(overlayType);

            var width  = originalImage.CurrentImage.Width;
            var height = originalImage.CurrentImage.Height;

            if (File.Exists(str))
            {
                try
                {
                    var newImage = OverlayHelper.GetNewColorImage("#c9c9c9", width, height);

                    ////using (var saturation = new MagickWand(width, height, new PixelWand("#202020", 0.5)))
                    ////{
                    ////    originalImage.CurrentImage.CompositeImage(saturation, CompositeOperator.SaturateCompositeOp, 0, 0);
                    ////}

                    newImage.CurrentImage.CompositeImage(originalImage, CompositeOperator.SoftLightCompositeOp, point.X, point.Y);

                    using (MagickWand overlayWand = new MagickWand(str))
                    {
                        if (overlayWand.CurrentImage.Height != originalImage.CurrentImage.Height)
                        {
                            // our images are always square, so:
                            overlayWand.CurrentImage.ResizeImage(height, height);
                        }

                        using (var overlayShadowed = overlayWand.CloneMagickWand())
                        {
                            ////using (var whitePixelWand = new PixelWand(ColorName.White))
                            ////{
                            ////    overlayShadowed.CurrentImage.BackgroundColor = whitePixelWand;
                            ////    overlayShadowed.CurrentImage.ShadowImage(80, 5, 5, 5);
                            ////    overlayShadowed.CurrentImage.CompositeImage(overlayWand, CompositeOperator.CopyCompositeOp, 0, 0);
                            ////}

                            newImage.CurrentImage.CompositeImage(overlayShadowed, CompositeOperator.OverCompositeOp, point.X, point.Y);
                        }
                    }

                    return(newImage);
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    this.Logger.ErrorException("Error loading overlay: {0}", exception, overlayType);
                }
            }
            else
            {
                this.Logger.Warn(string.Concat("SoundCloud - Undefined overlay type: ", overlayType), new object[0]);
            }

            return(originalImage);
        }
        public void MediaBrowserResizePerformanceImageTest()
        {
            for (var i = 0; i < 100; i++)
            {
                using (var wand = new MagickWand(TestImageBackdrop))
                {
                    var w = wand.CurrentImage.Width;
                    var h = wand.CurrentImage.Height;

                    using (var mwr = wand.CloneMagickWand())
                    {
                        var newW = 1280;
                        var newH = 720;
                        mwr.CurrentImage.ResizeImage(newW, newH, FilterTypes.CatromFilter);
                        mwr.SaveImage(Path.Combine(SaveDirectory, Guid.NewGuid().ToString() + ".jpg"));
                    }
                }
            }
        }