ASP. net2.0 image format conversion

Source: Internet
Author: User

 

Click to close this advertisement
 
 

Note: This article implements
Convert the image format as needed (select from the drop-down list );
Click fileupload to immediately display the image (JS implementation) skills;

 

Step 1: Open the page

Step 2: select a jpg image

. Net/images/p_blog_csdn.net/21as. Net/289247/o_t2.gif ">

Step 3: convert to the GIF format to see that the image quality is reduced.

 

background Code : using system;
using system. data;
using system. configuration;
using system. collections;
using system. web;
using system. web. security;
using system. web. ui;
using system. web. UI. webcontrols;
using system. web. UI. webcontrols. webparts;
using system. web. UI. htmlcontrols;
using system. io;
using system. drawing;
Public partial class _ default: system. web. UI. page
{< br> protected void page_load (Object sender, eventargs e)
{< BR >}< br> protected void button#click (Object sender, eventargs E)
{< br> string filepath = fileupload1.postedfile. filename;
string filename = filepath. substring (filepath. lastindexof ("\") + 1);
string serverpath = server. mappath ("images/") + system. datetime. now. tostring ("yyy-mm-dd-hh-mm-SS") + session. sessionid + filename;

If (dropdownlist1.selectedvalue = "GIF ")
{
Convertimage (fileupload1.postedfile. filename, system. Drawing. imaging. imageformat. GIF, serverpath + ". GIF ");
}
Else if (dropdownlist1.selectedvalue = "Jpeg ")
{
Convertimage (fileupload1.postedfile. filename, system. Drawing. imaging. imageformat. JPEG, serverpath + ". jpg ");
}
Else if (dropdownlist1.selectedvalue = "BMP ")
{
Convertimage (fileupload1.postedfile. filename, system. Drawing. imaging. imageformat. BMP, serverpath + ". BMP ");
}
Else
{
// Clear moon left for everyone http://blog.csdn.Net/21as.Net
}
}

Public void convertimage (string filename, system. Drawing. imaging. imageformat desiredformat, string

Listview class with printing function
Read the background data to the Excel file at the front end and use JavaScript
How to pop up MessageBox in ASP. NET
Introduction to variable reference and transmission in Asp.net multi-layer architecture
Use the query analyzer provided by Excel to quickly export data from SQL Server (common class)
Draw a straight line using GDI +
C # Call the Windows Printer adding wizard
Use global mouse and keyboard events to implement applications Program Automatic lock
Double-click the Treeview node so that the child nodes are not expanded and not collapsed.
Use C # To convert UNIX Timestamp
C #2.0 create a generic instance in factory Mode
C # simple example of printing text files
How to set the size of uploaded attachments in ASP. NET
Example used by listview in C # (Simple Internet cafe billing system)
Page. ispostback and autopostback
JS prompts a solution for "missing objects"
ASP. net2.0 image format conversion
Events in global. asax should pay attention to those operations and comments on Related Frequently asked questions.
C # Port Scanner)
How to delete the records of the internal layer sub-datalist
Name)
{
Try
{
System. Drawing. Image imgfile = system. Drawing. image. fromfile (filename );
Imgfile. Save (listview class with printing function
Read the background data to the Excel file at the front end and use JavaScript
How to pop up MessageBox in ASP. NET
Introduction to variable reference and transmission in Asp.net multi-layer architecture
Use the query analyzer provided by Excel to quickly export data from SQL Server (common class)
Draw a straight line using GDI +
C # Call the Windows Printer adding wizard
Use global mouse and keyboard events to automatically lock applications
Double-click the Treeview node so that the child nodes are not expanded and not collapsed.
Use C # To convert UNIX Timestamp
C #2.0 create a generic instance in factory Mode
C # simple example of printing text files
How to set the size of uploaded attachments in ASP. NET
Example used by listview in C # (Simple Internet cafe billing system)
Page. ispostback and autopostback
JS prompts a solution for "missing objects"
ASP. net2.0 image format conversion
Events in global. asax should pay attention to those operations and comments on Related Frequently asked questions.
C # Port Scanner)
How to delete the records of the internal layer sub-datalist
Name, desiredformat );
Image1.imageurl = listview class with printing function
Read the background data to the Excel file at the front end and use JavaScript
How to pop up MessageBox in ASP. NET
Introduction to variable reference and transmission in Asp.net multi-layer architecture
Use the query analyzer provided by Excel to quickly export data from SQL Server (common class)
Draw a straight line using GDI +
C # Call the Windows Printer adding wizard
Use global mouse and keyboard events to automatically lock applications
Double-click the Treeview node so that the child nodes are not expanded and not collapsed.
Use C # To convert UNIX Timestamp
C #2.0 create a generic instance in factory Mode
C # simple example of printing text files
How to set the size of uploaded attachments in ASP. NET
Example used by listview in C # (Simple Internet cafe billing system)
Page. ispostback and autopostback
JS prompts a solution for "missing objects"
ASP. net2.0 image format conversion
Events in global. asax should pay attention to those operations and comments on Related Frequently asked questions.
C # Port Scanner)
How to delete the records of the internal layer sub-datalist
Name;
Label1.text = "converted successfully, generated" + listview class with printing function
Read the background data to the Excel file at the front end and use JavaScript
How to pop up MessageBox in ASP. NET
Introduction to variable reference and transmission in Asp.net multi-layer architecture
Use the query analyzer provided by Excel to quickly export data from SQL Server (common class)
Draw a straight line using GDI +
C # Call the Windows Printer adding wizard
Use global mouse and keyboard events to automatically lock applications
Double-click the Treeview node so that the child nodes are not expanded and not collapsed.
Use C # To convert UNIX Timestamp
C #2.0 create a generic instance in factory Mode
C # simple example of printing text files
How to set the size of uploaded attachments in ASP. NET
Example used by listview in C # (Simple Internet cafe billing system)
Page. ispostback and autopostback
JS prompts a solution for "missing objects"
ASP. net2.0 image format conversion
Events in global. asax should pay attention to those operations and comments on Related Frequently asked questions.
C # Port Scanner)
How to delete the records of the internal layer sub-datalist

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.