How to convert image data to .jpg

I have a table with uid which is an unique number along with photo of image type.

Can i convert the photo stored as image with
UID.jpg, Please help.
searchsanjaysharmaAsked:
Who is Participating?
 
käµfm³d 👽Connect With a Mentor Commented:
If I recall correctly, using a DataReader, the data will be returned as a byte array. You can cast the column holding the data into a byte array, and then write those bytes out to disk.

e.g.

SqlDataReader reader = cmd.ExecuteReader();  // I assume you have set up your connection and command objects already

while (reader.Read())
{
    byte[] imgData = (byte[])reader["imgColumn"];
    string uid = (string)reader["uidColumn"];
    string filename = System.IO.Path.ChangeExtension(uid, ".jpg");

    System.IO.File.WriteAllBytes(filename, imgData);
}

Open in new window


If that approach doesn't work for you, then there are some classes that deal with specific SQL server types in .NET. We may need to involve some of those classes.
0
 
käµfm³d 👽Commented:
When you say image "data", what format is this data in? Is it a byte array, a base-64 encoding of the bytes, etc.?
0
 
searchsanjaysharmaAuthor Commented:
image datatype
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
käµfm³d 👽Commented:
OK, when you say "table", do you mean database table?
0
 
searchsanjaysharmaAuthor Commented:
yes
0
 
käµfm³d 👽Commented:
SQL Server or Oracle (or other)?
0
 
searchsanjaysharmaAuthor Commented:
sql server
0
 
searchsanjaysharmaAuthor Commented:
tx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.