473,320 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Convert images to Jpeg format

Hi,
I am creating a news and events page on my Intranet site and I wish to
allow people to upload an image with there news to my site. The text and
image are all stored in an SQL database. I have been successful in uploading
Jpeg files and downsampling them to a size that fits the web site. My next
challange is to convert other common file types (BMP, GIF, TIF) to jpegs as
well. Can this be done using the image object in ASP.net, if so could
somebody show me some sample code. Is it better if I just stop people from
uploading formats other than JPGs. If so can some body show me sample code
of how to stop the unwanted files from being uploaded.

Thanks
Kenneth
Nov 19 '05 #1
2 2767
Hi Kenneth

Please have a look at this site:
http://www.codeproject.com/csharp/do...nvertimage.asp
hope it helps.

Regards,
WeiChung

"Kenneth Keeley" <ke*******@hotmail.com> wrote in message
news:ez**************@TK2MSFTNGP15.phx.gbl...
Hi,
I am creating a news and events page on my Intranet site and I wish to
allow people to upload an image with there news to my site. The text and
image are all stored in an SQL database. I have been successful in
uploading
Jpeg files and downsampling them to a size that fits the web site. My next
challange is to convert other common file types (BMP, GIF, TIF) to jpegs
as
well. Can this be done using the image object in ASP.net, if so could
somebody show me some sample code. Is it better if I just stop people from
uploading formats other than JPGs. If so can some body show me sample code
of how to stop the unwanted files from being uploaded.

Thanks
Kenneth

Nov 19 '05 #2
Hi Kenneth,

Once you put any supported image type into an Image or Bitmap object, it is
easily converted to any other supported format, by using the parameters of
the Save method of the Image class.

To prevent files other than JPEGs from being uploaded, use some JavaScript
validation on the client to check the value attribute of the File Upload
element in the form. It will be a string containing the full path of the
file to be uploaded Use Path.GetExtension() to get the extension, and if it
isn't "jpg" don't allow the form to submit.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Kenneth Keeley" <ke*******@hotmail.com> wrote in message
news:ez**************@TK2MSFTNGP15.phx.gbl...
Hi,
I am creating a news and events page on my Intranet site and I wish to
allow people to upload an image with there news to my site. The text and
image are all stored in an SQL database. I have been successful in uploading Jpeg files and downsampling them to a size that fits the web site. My next
challange is to convert other common file types (BMP, GIF, TIF) to jpegs as well. Can this be done using the image object in ASP.net, if so could
somebody show me some sample code. Is it better if I just stop people from
uploading formats other than JPGs. If so can some body show me sample code
of how to stop the unwanted files from being uploaded.

Thanks
Kenneth

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Suzanne | last post by:
Hi all, I'm attempting to save images (that are in jpeg format) to a database column of type image. I've read over the Microsoft Knowledge Base articles for this and I can get things working...
2
by: Rock | last post by:
Hi,all: how to convert VBA #date# format (ex: #2004/3/6#) to C# code ? here are vba code : Dim objUserPerm As Office.UserPermission Set objUserPerm =...
0
by: Neeraj | last post by:
Hi I have problem to make Bitmap from pixel data coming from Dicom which have jpeg format. which Transfer Sysntax is "1.2.840.10008.1.2.4.57" IF any body have idea about that plz share with me...
1
by: solomon_13000 | last post by:
How do I actually convert different video format (avi,mpeg,mp4, etc) file to a flash format and view it as flash? People would upload their video files on my server and my server will do the...
1
by: Just D. | last post by:
All, Does anybody know some library to resize/convert images on the fly? I'm especially interested in JPG/GIF/TIF images. Also maybe BMP, but not critical. Are we having some kind of a standard,...
5
nirmalsingh
by: nirmalsingh | last post by:
i am getting date format in string as 30-11-2006 05:59:44 PM . i want to convert in the format of yyyy-mm-dd hh:mm:ss to sore it in mysql database. Help me with sample coding plz..
1
by: madhavarao | last post by:
capture form to save into JPEG format in windows application uisng C#.net. But i want to save full form instead of active window. Thanks in advance
0
by: VinDiesal | last post by:
Hi Buddies, I want the Sample source code about How to convert Dss audio format to wav format in .net. Please anybody send the source code for this.
3
by: Academia | last post by:
I have a vs2003 project (actually 44 of them) that I want to convert to VS2005 format. To fix a usercontrol file I created the Designer.vb file and moved the Inherited and Class ( change to...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.