public void Execute(PipelineContext context, MagickImage magickImage) { foreach (MagickGeometry dimensions in Config.Geometries) { using (MagickImage dimensionsMagickImage = (MagickImage)magickImage.Clone()) { PipelineContext contextClone = context.Clone(); contextClone.AppendPath(dimensions.ToString()); if (dimensions.Width < 0 || dimensions.Height < 0) { Logger.Fatal("The height and width of dimensions can not be negative."); } if (dimensions.Width == 0 && dimensions.Height == 0) { Logger.Fatal("Both height and width in the dimensions configuration were 0, please specify at least one."); } dimensionsMagickImage.FilterType = Config.Filter; dimensionsMagickImage.Resize(dimensions); contextClone.Next(dimensionsMagickImage); } } }
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); } } }
/// <summary>Start building all images.</summary> /// <exception cref="InvalidOperationException">If the configuration is malformed.</exception> public void Execute() { Logger.Trace("Executed build command, started working."); Build build = Config.Build; if (build == null) { throw new ConfigurationException("Build command was called, but no build configuration was defined, doing nothing."); } List <DataSource> input = build.Input; if (input == null) { throw new ConfigurationException("Build command was called but build.input configuration was not specified, this is required."); } DataResolver resolver = new DataResolver(input); List <ResolvedData> resolvedDatas = new DataResolver(input).Data; Logger.Debug("Found {0} files matching collection pattern.", resolvedDatas.Count); List <IBuildStep> pipeline = new List <IBuildStep>(); if (Config.Build.Metadata != null) { pipeline.Add(new ExifBuildStep(Config)); pipeline.Add(new IptcBuildStep(Config)); } if (Config.Build.Recolor != null) { if (Config.Build.Recolor.Mask != null) { resolver.ResolveAdditional("masks", Config.Build.Recolor.Mask.Sources); } pipeline.Add(new RecolorBuildStep(Config)); } if (Config.Build.Resize != null) { pipeline.Add(new ResizeBuildStep(Config)); } pipeline.Add(new WriteBuildStep()); Parallel.ForEach(resolvedDatas, (resolvedData) => { PipelineContext context = new PipelineContext(resolver, pipeline, resolvedData); context.AppendPath("export"); using (MagickImage magickImage = resolvedData.ToMagickImage()) { context.Next(magickImage); } Logger.Info("Finished all exports for {0}.", resolvedData); }); }