Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > ASP.NET > ASP.NET Image > ASP.NET Resize Image



Clound SSD Virtual Server

ASP.NET Resize Image

ASP.NET Resize Image การ Resize Image เป็นการย่อขนาดของรูปภาพ เพื่อให้มีขนาดเล็กลง ทั้งนี้เพื่อเป็นการเพิ่มความเร็วในการแสดงผลไปยังเว็บไซต์ และลดประมาณ Bandwidth ของเว็บไซต์ การ Resize Image ถ้าหากต้องการความคมชัดมาก ๆ ผมแนะนำให้ใช้ชนิดแบบ png แต่ก็จะต้องแลกกับปริมาณไฟล์ที่มีขนาดใหญ่มากกว่า jpeg

Language Code : VB.NET || C#

Framework : 1,2,3,4

AspNetResizeImages.aspx

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>

<script runat="server">

	Sub Page_Load(sender As Object, e As EventArgs)	
		Dim intWidth,intHeight As Integer
		Dim FileName,NewFileName As String

		intWidth = 	100 '*** Fix Width ***'
		intHeight = 0   '*** If = 0 Auto Re-Cal Size ***'


		FileName = "MyImages/Mygirl.jpg"
		NewFileName = "MyImages/New_Mygirl.jpg"


		Dim objGraphic As System.Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath(FileName))

		Dim objBitmap As Bitmap
		'*** Calculate Height ***'
		If intHeight > 0 Then
			objBitmap = New Bitmap(objGraphic, intWidth, intHeight)
		Else
			If objGraphic.Width > intWidth Then
				Dim ratio As Double = objGraphic.Height / objGraphic.Width
				intHeight = ratio * intWidth
				objBitmap = New Bitmap(objGraphic, intWidth, intHeight)
			Else
				objBitmap = New Bitmap(objGraphic)
			End If
		End If
		
		'*** Save As  ***'
		objBitmap.Save(Server.MapPath(NewFileName), objGraphic.RawFormat) 
		
		'*** Close ***'
		objGraphic.Dispose()
		
		'*** Nothing ***'
		objBitmap = Nothing
		objGraphic = Nothing

		'*** View Images ***'
		Me.imgPicture.ImageURL = NewFileName
		
	End Sub

</script>
<html>
<head>
<title>ThaiCreate.Com ASP.NET - Images (System.Drawing)</title>
</head>
<body>
	<form id="form1" runat="server">
		<asp:Image id="imgPicture" runat="server" />
	</form>
</body>
</html>
</form>


Screenshot

ASP.NET Image


ASP.NET Image

จากตัวอย่างผมได้ทำการ Resize ไฟล์ความกว้าง 350*441 (43 KB) ให้เป็น 100*126 (4 KB)






   
Share


ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท


ลองใช้ค้นหาข้อมูล


   


Bookmark.   
       
  By : ThaiCreate.Com Team (บทความเป็นลิขสิทธิ์ของเว็บไทยครีเอทห้ามนำเผยแพร่ ณ เว็บไซต์อื่น ๆ)
  Score Rating :  
  Create/Update Date : 2008-10-26 20:19:23 / 2009-06-03 07:56:21
  Download : Download  ASP.NET Resize Image
 Sponsored Links / Related

 
ASP.NET Create Image
Rating :

 
ASP.NET Write Text to Image
Rating :

 
ASP.NET Write Text to Picture
Rating :

 
ASP.NET (Watermark) Upload and Write Text to Picture
Rating :

 
ASP.NET Add Logo/CopyRight to Image
Rating :

 
ASP.NET Upload and Add Logo/CopyRight to Image
Rating :

 
ASP.NET Create Thumbnail Image
Rating :

 
ASP.NET Upload & Resize Image
Rating :

 
ASP.NET Upload Resize Insert to Database
Rating :

 
ASP.NET Multiple Upload & Multiple Resize
Rating :


ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่