We’ve tried to understand the underline code with the help of dotPeek reflector and we’ve found below line of code causing the issue when we pass the System.IO.MemoryStream in the ResizeImageStream() method.

> FileUtil.CopyStream(inputStream, (Stream) memoryStream, 8192);

Note: It's working fine when we pass the System.IO.Stream

To fix that we’ve created separate class (copied from the Sitecore.Resources.Media.ImageEffectsResize) and updated ResizeImageStream() method. Here is the updated method:

    public virtual Stream ResizeImageFromStream(Stream inputStream, TransformationOptions options, ImageFormat outputFormat)
    {
        Assert.ArgumentNotNull((object)inputStream, "inputStream");
        Assert.ArgumentNotNull((object)options, "options");
        Assert.ArgumentNotNull((object)outputFormat, "outputFormat");
        ResizeOptions resizeOptions = this.GetResizeOptions(options);
        if (resizeOptions.IsEmpty)
            return inputStream;
        if (inputStream.Length > Settings.Media.MaxSizeInMemory)
        {
            Tracer.Error((object)"Could not resize image stream as it was larger than the maximum size allowed for memory processing.");
            return (Stream)null;
        }
        if (Settings.Media.UseLegacyResizing)
            return this.ResizeLegacy(inputStream, options, outputFormat);
        Resizer resizer = new Resizer();
        using (Bitmap originalBitmap = new Bitmap((Stream)inputStream))
        {
            Size frameSize = resizer.GetFrameSize(originalBitmap, resizeOptions);
            if (originalBitmap.Size.Equals((object)frameSize))
            {
                inputStream.Seek(0L, SeekOrigin.Begin);
                return (Stream)inputStream;
            }
            using (Bitmap resizedBitmap = resizer.Resize(originalBitmap, resizeOptions, outputFormat))
            {
                MemoryStream memoryStream = new MemoryStream();
                memoryStream.Seek(0L, SeekOrigin.Begin);
                ImageCodecInfo encoderInfo = this.FindEncoderInfo(outputFormat);
                EncoderParameters encoderParams = new EncoderParameters(1);
                encoderParams.Param[0] = new EncoderParameter(Encoder.Quality, (long)options.Quality);
                resizedBitmap.Save((Stream)memoryStream, encoderInfo, encoderParams);
                memoryStream.SetLength(memoryStream.Position);
                memoryStream.Seek(0L, SeekOrigin.Begin);
                return (Stream)memoryStream;
            }
        }
    }


Also we need to apply below patch:

    <pipelines>
      <getMediaStream>
        <processor type="Demo.Foundation.MediaLibrary.Infrastructure.Pipelines.GetMediaStream.ThumbnailProcessor, Demo.Foundation.MediaLibrary"
                   patch:instead="*[@type='Sitecore.Resources.Media.ThumbnailProcessor, Sitecore.Kernel']" />
      </getMediaStream>
    </pipelines>

Thank you,