I'm using Magick.NET-Q16-AnyCPU (7.4.3) with .NET Core 2.0, need to batch process ~25,000 images, (make square, resize to large/thumb), just using a single thread at the moment:
Code: Select all
using (MagickImage image = new MagickImage(inputFile))
{
image.ColorFuzz = new Percentage(1);
image.Trim();
var largestDimension = Math.Max(image.Width, image.Height);
image.BackgroundColor = MagickColor.FromRgb(255, 255, 255);
image.Extent(largestDimension, largestDimension, Gravity.Center);
image.Format = MagickFormat.Jpg;
image.Quality = 65;
image.Resize(600, 600);
image.Write(largeOutputFile);
image.Resize(200, 200);
image.Write(thumbOutputFile);
}
Edit: it's the Resize command that starts slowing down, for the first images:
After ~300 images:500x331px
Trim: 2.9678ms
Extent: 4.4123ms
Large: 24.8456ms
Thumb: 14.398ms
-
500x275px
Trim: 2.5952ms
Extent: 3.477ms
Large: 17.557ms
Thumb: 13.7364ms
-
500x357
Trim: 5.8368ms
Extent: 12.1412ms
Large: 2656.029ms
Thumb: 18.721ms
-
500x298
Trim: 5.7799ms
Extent: 11.5524ms
Large: 2647.8159ms
Thumb: 22.1286ms
-
500x261
Trim: 5.9073ms
Extent: 12.3215ms
Large: 2743.2966ms
Thumb: 19.2876ms
-
Edit2: Ok, so when the slowdown starts imagemagick starts writing to %temp%/magick-* instead of (presumably) doing the operations in memory. Why is it doing this? The process is only using 100mb memory, the machine has 32GB memory with ~26GB free.