Converting a multi page tiff file to base64 string by using known conversion methods seems to contain just a single page of it.
I'm getting the multi page tiff file from local disk:
Image multiPageImage = Image.FromFile(fileName);
Converting it to base64 string:
base64string = ImageToBase64(multiPageImage, ImageFormat.Tiff);
public static string ImageToBase64(Image image, ImageFormat format)
{
using (MemoryStream ms = new MemoryStream())
{
// Convert Image to byte[]
image.Save(ms, format);
byte[] imageBytes = ms.ToArray();
// Convert byte[] to Base64 String
string base64String = Convert.ToBase64String(imageBytes);
image.Dispose();
return base64String;
}
}
Then converting base64 to image back and saving it on the local disk to control the result:
public static Image ConvertBase64ToImage(string base64string)
{
byte[] bytes = Convert.FromBase64String(base64string);
Image image;
using (MemoryStream ms = new MemoryStream(bytes))
{
image = Image.FromStream(ms);
image.Save(@"C:\newTiff.tiff", ImageFormat.Tiff);
}
return image;
}
But result image has only single frame. That's why I'm asking if it is possible to have all frames in base64 string?