diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index 5092cfab3..a25f31878 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -18,6 +18,8 @@ namespace ImageProcessor using System.Drawing.Imaging; using System.IO; using System.Linq; + using System.Threading; + using ImageProcessor.Imaging; using ImageProcessor.Processors; #endregion @@ -683,18 +685,39 @@ namespace ImageProcessor { ImageCodecInfo imageCodecInfo = ImageCodecInfo.GetImageEncoders() - .FirstOrDefault( - ici => ici.MimeType.Equals("image/jpeg", StringComparison.OrdinalIgnoreCase)); + .FirstOrDefault(ici => ici.MimeType.Equals("image/jpeg", StringComparison.OrdinalIgnoreCase)); if (imageCodecInfo != null) { - this.Image.Save(filePath, imageCodecInfo, encoderParameters); + for (int i = 0; i < 3; i++) + { + try + { + this.Image.Save(filePath, imageCodecInfo, encoderParameters); + break; + } + catch (IOException) + { + Thread.Sleep(200); + } + } } } } else { - this.Image.Save(filePath, this.ImageFormat); + for (int i = 0; i < 3; i++) + { + try + { + this.Image.Save(filePath, this.ImageFormat); + break; + } + catch (IOException) + { + Thread.Sleep(200); + } + } } } diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Test_Website_NET45.csproj b/src/TestWebsites/NET45/Test_Website_NET45/Test_Website_NET45.csproj index a041c692a..318733563 100644 --- a/src/TestWebsites/NET45/Test_Website_NET45/Test_Website_NET45.csproj +++ b/src/TestWebsites/NET45/Test_Website_NET45/Test_Website_NET45.csproj @@ -188,7 +188,9 @@ - + + Designer +