Browse Source

Making the save method a little more robust

Former-commit-id: 439b084d1c9224e1154a8aee67b7dd706fe29e79
af/merge-core
James South 12 years ago
parent
commit
a454aeeb4d
  1. 31
      src/ImageProcessor/ImageFactory.cs
  2. 4
      src/TestWebsites/NET45/Test_Website_NET45/Test_Website_NET45.csproj

31
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);
}
}
}
}

4
src/TestWebsites/NET45/Test_Website_NET45/Test_Website_NET45.csproj

@ -188,7 +188,9 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="config\imageprocessor\cache.config" />
<Content Include="config\imageprocessor\cache.config">
<SubType>Designer</SubType>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="config\imageprocessor\processing.config" />

Loading…
Cancel
Save