Solved

How to convert image data to .jpg

Posted on 2013-11-26
8
279 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

631 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