Solved

How to convert image data to .jpg

Posted on 2013-11-26
8
277 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Question has a verified solution.

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

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

679 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