Solved

How to convert image data to .jpg

Posted on 2013-11-26
8
276 Views
Last Modified: 2013-11-27
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.
0
Comment
Question by:searchsanjaysharma
  • 4
  • 4
8 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39677717
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
 

Author Comment

by:searchsanjaysharma
ID: 39677737
image datatype
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39677750
OK, when you say "table", do you mean database table?
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:searchsanjaysharma
ID: 39677768
yes
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39677809
SQL Server or Oracle (or other)?
0
 

Author Comment

by:searchsanjaysharma
ID: 39677842
sql server
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39678243
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
 

Author Closing Comment

by:searchsanjaysharma
ID: 39682668
tx
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question