Resizing of animated GIF files throws an exception


Description

When resizing animated GIF files using the below approaches the "Could not run the 'getMediaStream' pipeline" error message may occur in Sitecore log files:

Error message:

ERROR Could not run the 'getMediaStream' pipeline for '/sitecore/media library/Files/2-col-img'. Original media data will be used.
 Exception: System.OverflowException
 Message: Arithmetic operation resulted in an overflow.
 Source: Sitecore.Kernel
  at Sitecore.ImageLib.ThumbMaker.GetSourceByteAt(Int32 x, Int32 y)
  at Sitecore.ImageLib.ThumbMaker.IndexedRezise(Int32 xSize, Int32 ySize, Boolean preserveResolution)s
  at Sitecore.ImageLib.Resizer.ResizeGif(Bitmap image, Size imageSize, Size frameSize, Color frameColor, Boolean preserveResolution)
  at Sitecore.ImageLib.Resizer.Resize(Bitmap bitmap, Size imageSize, Size frameSize, Color frameColor, Boolean preserveResolution, ImageFormat format, InterpolationMode interpolationMode, CompositingMode compositingMode, PixelOffsetMode pixelOffsetMode)
  at Sitecore.ImageLib.Resizer.Resize(Bitmap bitmap, ResizeOptions options, ImageFormat format, InterpolationMode interpolationMode)
  at Sitecore.Resources.Media.ImageEffectsResize.ResizeImageStream(Stream inputStream, TransformationOptions options, ImageFormat outputFormat)
  at Sitecore.Resources.Media.ResizeProcessor.Process(GetMediaStreamPipelineArgs args)
  at (Object , Object[] )
  at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
  at Sitecore.Resources.Media.Media.GetStreamFromPipeline(MediaOptions options, Boolean& canBeCached)

Solution

To resolve the issue, download and install one of the following patches depending on the Sitecore version you use:

The patch will disable resizing of GIF images on the server side and leverage it to the browser.