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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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
All Courses

From novice to tech pro — start learning today.