473,976 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2798
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*******@hotm ail.com> wrote in message
news:ez******** ******@TK2MSFTN GP15.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.GetExtensi on() 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*******@hotm ail.com> wrote in message
news:ez******** ******@TK2MSFTN GP15.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
1939
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 when the image is in a gif format - but not when the image is in a jpeg format - I get the error that the file can not be found (& I've checked - the file is there)! My code is :
2
4874
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 = ActiveWorkbook.Permission.Add("user@domain.com", msoPermissionRead + msoPermissionEdit, #12/31/2005#) a to c# ?? I don't know how to convert this code to C#? and I have already try it use DateTime format, but it happen argument error. anyone have the same problem ? ...
0
1341
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 regards Neeraj Kumar
1
3813
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 conversion automatically to flash format. When people preview the video files, they would see them in flash. I am interested to use visual c++ to do the conversion. How is it done? Your help is kindly appreciated. Regards
1
2288
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, maybe freeware or open source library for that? The primary thing that I need is to decrease the image to show a small version on the page. The original color image can be huge x000 by x000 pixels, but I don't need to load the whole image into...
5
19196
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
1405
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
1325
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
2418
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 partial class) lines to it so it started with: <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()_ Partial Class UserControl1
0
10352
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10171
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11818
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11408
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10907
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
10083
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7604
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
5153
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.