Beispiel #1
0
        public IEnumerable <Failure> Check()
        {
            List <Failure> failures = new List <Failure>();

            foreach (ResolutionMatchesConfig config in Config)
            {
                DataResolver resolver = new DataResolver(config.Source);
                resolver.ResolveAdditional("target", config.Target);

                foreach (ResolvedData resolvedFile in resolver.Data)
                {
                    using (IMagickImage magickSource = resolvedFile.ToMagickImage())
                    {
                        ResolvedData resolvedData = resolver.ResolvedData("target", resolvedFile, config.Pattern);

                        if (resolvedData == null)
                        {
                            continue;
                        }

                        using (IMagickImage magickTarget = resolvedData.ToMagickImage())
                        {
                            if (magickSource.Height != magickTarget.Height || magickSource.Width != magickTarget.Width)
                            {
                                failures.Add(new Failure(resolvedFile, "resolutions does not much with target."));
                            }
                        }
                    }
                }
            }

            return(failures);
        }
Beispiel #2
0
        public void Execute(PipelineContext context, MagickImage magickImage)
        {
            ResolvedData maskFileInfo = context.DataResolver.ResolvedData("masks", context.ResolvedData, Config.Mask.Pattern);

            if (Config.Original)
            {
                PipelineContext contextClone = context.Clone();
                contextClone.AppendPath(OriginalDirectory);
                contextClone.Next(magickImage);
            }

            if (maskFileInfo != null)
            {
                using (MagickImage maskMagickImage = maskFileInfo.ToMagickImage())
                {
                    magickImage.SetWriteMask(maskMagickImage);
                }
            }

            foreach (Modulation modulate in Config.Modulation)
            {
                using (MagickImage modulatedMagickImage = (MagickImage)magickImage.Clone())
                {
                    PipelineContext contextClone = context.Clone();
                    contextClone.AppendPath($"{modulate.Name}");
                    contextClone.AppendPrefix(modulate.Prefix ?? modulate.Name.Substring(0, 1));

                    modulatedMagickImage.Modulate(modulate.Brightness, modulate.Saturation, modulate.Hue);
                    modulatedMagickImage.RemoveWriteMask();

                    contextClone.Next(modulatedMagickImage);
                }
            }
        }