Note: all scripts examples included in these Web pages are absolutely free. You can copy, use, and modify these scripts anyway you want. The scripts are published without warranty of any kind.
This example is an ASP script creating the image. It does the following:
| File reduce.asp |
<%
Response.Contenttype="image/jpeg"
Set g=CreateObject("shotgraph.image")
' This is the absolute path to image file.
' You can get it anyway as you want, for example using
' Request.Form or Request.QueryString for file name and then
' adding that value to directory path.
' Current string means the image file is located in the same directory
' with ASP script
file_name = Server.MapPath("big01.jpg")
' The maximal dimensions for new image
x_new=100
y_new=100
Main()
Sub Main()
t=g.GetFileDimensions(file_name,x,y)
if x<=0 or y<=0 then Exit Sub
if x/x_new > y/y_new then
xset=x_new
yset=y*x_new\x
else
yset=y_new
xset=x*y_new\y
end if
if xset<=0 then xset=1
if yset<=0 then yset=1
g.CreateImage xset,yset,4
g.InitClipboard x,y
g.SelectClipboard True
g.ReadImage file_name,pal,0,0
g.Stretch 0,0,xset,yset,0,0,x,y,"SRCCOPY","HALFTONE"
g.SelectClipboard False
Response.BinaryWrite g.JpegImage(70,0,"")
End Sub
%>
|