Ensure disposal of opened Image instances (#249)

This commit is contained in:
Malte Rosenbjerg 2021-11-01 18:14:06 +01:00
parent c2d28055c1
commit b217ca4af0

View file

@ -303,12 +303,13 @@ public static bool Join(string output, params string[] videos)
public static bool JoinImageSequence(string output, double frameRate = 30, params ImageInfo[] images)
{
var tempFolderName = Path.Combine(GlobalFFOptions.Current.TemporaryFilesFolder, Guid.NewGuid().ToString());
var temporaryImageFiles = images.Select((image, index) =>
var temporaryImageFiles = images.Select((imageInfo, index) =>
{
FFMpegHelper.ConversionSizeExceptionCheck(Image.FromFile(image.FullName));
var destinationPath = Path.Combine(tempFolderName, $"{index.ToString().PadLeft(9, '0')}{image.Extension}");
using var image = Image.FromFile(imageInfo.FullName);
FFMpegHelper.ConversionSizeExceptionCheck(image);
var destinationPath = Path.Combine(tempFolderName, $"{index.ToString().PadLeft(9, '0')}{imageInfo.Extension}");
Directory.CreateDirectory(tempFolderName);
File.Copy(image.FullName, destinationPath);
File.Copy(imageInfo.FullName, destinationPath);
return destinationPath;
}).ToArray();