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 > ASP Image > ASP Resize Image



Clound SSD Virtual Server

ASP Resize Image

ASP Resize Image ในการเขียน ASP ทำการ Resize รูปภาพผมใช้ Component ของ OWC10.ChartSpace ซึ่งมีอยู่ใน Windows แล้วสามารถเรียกงานได้ในทันที

Syntax

Server.CreateObject("OWC10.ChartSpace")


Samle 1 ตัวอย่างแรกจะเป็นการ Resize โดยส่งออกแบบ Binary

AspResizeImages.asp

<% 
	Option Explicit
	Dim Chs, objConst,NewWidth,NewHeight
	Dim FileName,OutFormat
	FileName = "mygirl.jpg"	
	OutFormat = "Jpg" '*** Gif,Png ***'
	NewWidth = "100" '*** Set new Width , Height automatic caculate ***'
	NewHeight = 0 '*** Auto Resize ***'
	 
	'*** Get Images Width & Height ***'
	Dim objFso,myImg,Width,Height
	Set objFso = CreateObject("Scripting.FileSystemObject")
	IF objFso.FileExists(Server.MapPath(FileName))  Then	
		set myImg = Loadpicture(Server.MapPath(FileName))
		Width = Round(myImg.width / 26.4583)
		Height = Round(myImg.height / 26.4583)
		NewHeight = Round((NewWidth*Height)/Width)
		'NewHeight = 100
		'NewWidth = Round((NewHeight*Width)/Height) '*** or Automatic Height ***'
	End If
	'*************** End *************'

	Set Chs = Server.CreateObject("OWC10.ChartSpace") 
	Set objConst = Chs.Constants  
	 
	Chs.Interior.SetTextured Server.MapPath(FileName), objConst.chStretchPlot, , objConst.chAllFaces  
	Chs.border.color = -3  

	Response.BinaryWrite Chs.GetPicture(OutFormat, NewWidth, NewHeight)  
	
	Set objConst = Nothing
	Set Chs = Nothing
%>


ASPViewResizeImages.asp

<% Option Explicit %>
<html>
<head>
<title>ThaiCreate.Com ASP Resize Images</title>
</head>
<body>
	<b>Oritial Size</b><br>
	<img src="mygirl.jpg">
	<hr>
	<b>New Size</b>
	<br>
	<img src="AspResizeImages.asp">
	</body>
</html>

Screenshot

ASP & Resize



Sample 2 ตัวอย่างที่สองจะเป็นการ Save เป็นไฟล์ใหม่ลงในตำแหน่งที่ต้องการ

AspResizeImages2.asp

<% Option Explicit %>
<html>
<head>
<title>ThaiCreate.Com ASP Resize Images</title>
</head>
<body>
<b>Oritial Size</b><br>
<img src="mygirl.jpg">
<hr>
<b>New Size</b>
<br>
	<%
		Dim Chs, objConst,NewWidth,NewHeight
		Dim FileName,OutFormat,OutFileName
		FileName = "mygirl.jpg"	
		OutFormat = "Jpg" '*** Gif,Png ***'
		OutFileName = "MyResize/mygirl.jpg"
		NewWidth = "100" '*** Set new Width , Height automatic caculate ***'
		NewHeight = 0 '*** Auto Resize ***'
		 
		'*** Get Images Width & Height ***'
		Dim objFso,myImg,Width,Height
		Set objFso = CreateObject("Scripting.FileSystemObject")
		IF objFso.FileExists(Server.MapPath(FileName))  Then	
			set myImg = Loadpicture(Server.MapPath(FileName))
			Width = Round(myImg.width / 26.4583)
			Height = Round(myImg.height / 26.4583)
			NewHeight = Round((NewWidth*Height)/Width)
			'NewHeight = 100
			'NewWidth = Round((NewHeight*Width)/Height) '*** or Automatic Height ***'
		End If
		'*************** End *************'

		Set Chs = Server.CreateObject("OWC10.ChartSpace") 
		Set objConst = Chs.Constants  
		 
		Chs.Interior.SetTextured Server.MapPath(FileName), objConst.chStretchPlot, , objConst.chAllFaces  
		Chs.border.color = -3  

	   'Chs.border.color = &H0000FF  
	   'Chs.border.Weight = 3  

		Chs.ExportPicture Server.MapPath(OutFileName),OutFormat,NewWidth,NewHeight
		
		Set objConst = Nothing
		Set Chs = Nothing
	%>
	<img src="<%=OutFileName%>">
</body>
</html>

Screenshot

ASP & Resize

ASP & Resize






   
Share


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


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


   


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

 
ASP Create Image
Rating :

 
ASP Write Text in Image
Rating :

 
ASP Upload and Resize Image
Rating :

 
ASP Resize Image and Insert to Database
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 อัตราราคา คลิกที่นี่