Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there is a way to convert image to a string
Posted
Comments
Dr.Walt Fair, PE 11-Aug-11 23:59pm    
Do you want to pack the image data into a string? If so, see below. If you have an image of some text and need to convert the text image to a string, that's a lot harder and you'd need to use some OCR.

Which is your case?

1 solution

Try
C#
public string ImageToBase64(Image image,
  System.Drawing.Imaging.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);
    return base64String;
  }
}

Reference Link :- Convert Image to String[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900