MIS Systems Thread, How do I export images from within SQL fields? in Technical; I have a database table containing images and names. I need to extract the images and save them as JPEGs ...
17th May 2010, 09:00 AM #1
How do I export images from within SQL fields?
I have a database table containing images and names. I need to extract the images and save them as JPEGs saved with the children's names as the filenames. This is because somebody has misplaced a disc and needs these images for the yearbook.
I can use Crystal Reports to get a pretty report displaying the name and images but that doesn't really help me.
Help would be much appreciated.
17th May 2010, 09:32 AM #2
Any good with C#.net?
I wrote a program to do this recently, but it was for SIMS, so it takes an XML file as input and outputs the photos to a specified folder.
If you use C#.net I'll send you the source code so you can adapt it, if not then if you can get a file containing the photo data (long string of seemingly random characters) and the names, either in XML or CSV, I'll adapt it for you and send you the exe
17th May 2010, 09:42 AM #3
I actually discovered that I could export the Crystal report to Word and from word the images can be saved. Since I have no intention of performing the 'save as' step for 160 records, I feel that this is an acceptable result
If you could ping me the C#, that would be awesome... I could then wait for the the guy to have performed the task on 100-odd of the images and then give him a folder full of nicely named files
Last edited by Ric_; 17th May 2010 at 09:45 AM.
17th May 2010, 09:45 AM #4
No problem, it's only about 6 lines of code to do the actual conversion:
static void Main(string args)
string RawData ="";
string strSource ="";
string strDest ="";
foreach(string arg in args)
strSource = arg.Substring(3, arg.Length - 3);
strDest = arg.Substring(3, arg.Length - 3);
if(strDest=="" || strSource=="")
Console.WriteLine(@"SIMS.net Image Grabber V1.0");
Console.WriteLine(@"/S:""DATA SOURCE"" Source file which raw image data should be read from");
Console.WriteLine(@"/D:""SAVE AS"" Name of the file the converted image should be saved to");
Console.WriteLine(@"The source file specified by the /S: parameter should be a plain text file");
Console.WriteLine(@"containing the string of text that makes up the raw data for the image");
Console.WriteLine(@"(this string of text is returned as the ""Photo"" field in a relevant");
Console.WriteLine(@"SIMS .net XML report). The system will convert this text in to a JPEG image,");
Console.WriteLine(@"and save that image to the file specified by the /D: parameter.");
TextReader inFile = new StreamReader(strSource);
RawData = inFile.ReadToEnd();
byte todecode = Convert.FromBase64String(RawData);
MemoryStream ms = new MemoryStream(todecode);
Image img = Image.FromStream(ms);
Seems this is an old version that does one image at a time, shouldn't be too difficult to adapt it though, the only really important part is the conversion of the photo data string from base 64
Last edited by LosOjos; 17th May 2010 at 09:48 AM.
By itgeek in forum Scripts
Last Post: 26th February 2010, 11:34 AM
By FN-GM in forum Scripts
Last Post: 29th July 2009, 01:14 PM
By tw15ns in forum MIS Systems
Last Post: 3rd January 2009, 03:38 PM
By garethedmondson in forum Office Software
Last Post: 11th December 2008, 03:22 PM
By cjohnsonuk in forum MIS Systems
Last Post: 20th March 2008, 01:42 PM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)