Fix for single source multi position images

main
exsersewo 2 years ago
parent c91d3975b7
commit 874dc64ea1
Signed by: exsersewo
GPG Key ID: 9C6DDF9AC9BA14A0
  1. 11
      src/Managers/ImageManager.Generation.cs

@ -35,7 +35,7 @@ public static partial class ImageManager
} }
string variant = null; string variant = null;
if (endpoint.Variants.Any() && TrueRandom.Next(0, 50) > 25) if (endpoint.Variants != null && endpoint.Variants.Any() && TrueRandom.Next(0, 50) > 25)
{ {
variant = endpoint.Variants.Random().Name; variant = endpoint.Variants.Random().Name;
} }
@ -145,9 +145,11 @@ public static partial class ImageManager
} }
int img = 0; int img = 0;
foreach (var src in sources) for(int x = 0; x < template.Positions.Count; x++)
{ {
var position = template.Positions.ElementAtOrDefault(img); var position = template.Positions.ElementAtOrDefault(x);
var src = sources.ElementAtOrDefault(img);
Stream imageData = null; Stream imageData = null;
if (File.Exists(src)) if (File.Exists(src))
@ -176,8 +178,11 @@ public static partial class ImageManager
image.Composite(tmp, Gravity.Northwest, position.X, position.Y, CompositeOperator.Over); image.Composite(tmp, Gravity.Northwest, position.X, position.Y, CompositeOperator.Over);
if (img + 1 < sources.Count())
{
img++; img++;
} }
}
return; return;
} }

Loading…
Cancel
Save