web 2.0

How to use ASP & Resize image

How to use ASP & Resize image This is learn/tutorial asp developers how to using ASP script Component  OWC10.ChartSpace Resize image

ShotDev Focus:
- ASP & Component  OWC10.ChartSpace Resize image

Example 1 Read from binary

asp_resize_image1.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
%>

asp_resize_image2.asp


<% Option  Explicit %>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<b>Oritial Size</b><br>
<img src="mygirl.jpg">
<hr>
<b>New Size</b>
<br>
<img src="asp_resize_image1.asp">
</body>
</html>

Create a asp file and save to path root-path/myasp/

Run
http://localhost/myasp/asp_resize_image2.asp

Screenshot

ASP & Resize image
.
.
.

Example 2 Create new image.

asp_resize_image3.asp


<% Option  Explicit %>
<html>
<head>
<title>ShotDev.Com Tutorial</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 calculator ***'
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>

Create a asp file and save to path root-path/myasp/

Run
http://localhost/myasp/asp_resize_image3.asp

Screenshot

ASP & Resize image

ASP & Resize image

.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.