Azure blobs and thumbnails

I have two images clear.jpg and thumbclear.jpg, the second one is a thumbnail I create from the first one with the following code: I am not doing any resize yet

  Bitmap bitmap = new Bitmap(File.InputStream);
  MemoryStream st = new MemoryStream();
     bitmap.Save(st, ImageFormat.Png);
     return st;

so then I upload both Images to blobs and I get their URIs and copy/paste them to browser. The first one is working fine,

but the second one gives me the following error:

The image "http://...thumbclear.png" cannot be displayed, because it contains errors.

So I supose it has something to do with the bitmap to stream. Any help will be appreciated.

**Edit The code I use to save the blob

public static CloudBlob SaveFileToBlob(MemoryStream stream, string blobContainerName, string filename, string extension, string contentType, int fileSize)
            if (stream != null)
                CloudBlobContainer _BlobContainer = SessionHelper.GetBlobContainer(blobContainerName);
                var permissions = new BlobContainerPermissions();
                permissions.PublicAccess = BlobContainerPublicAccessType.Container;

                Guid blobid = Guid.NewGuid();
                var blob = _BlobContainer.GetBlobReference(blobid.ToString() + "/" + filename);

                blob.Metadata["FileName"] = filename;
                blob.Metadata["Extension"] = extension;
                blob.Metadata["FileSize"] = fileSize.ToString();

                blob.Properties.ContentType = contentType;

                return blob;
                return null;


The solution was to set the stream position to zero before uploading to blob.

stream.Position = 0;

Need Your Help

Why does the setInterval callback execute only once?

javascript callback setinterval

I have this counter I made but I want it to run forever, it's really simple, what am I doing wrong here?