| 1 |
<% |
| 2 |
' This code will show you how to resize image. |
| 3 |
|
| 4 |
Dim oGraphic |
| 5 |
Set oGraphic = Server.CreateObject("PhotoSprite.Graphic") |
| 6 |
|
| 7 |
' Original image name |
| 8 |
oGraphic.SourceFile = Server.MapPath( "images/demo.jpg" ) |
| 9 |
|
| 10 |
' Destination image name, and can make the same as the original image name |
| 11 |
oGraphic.DestFile = Server.MapPath( "images/tmp/resize.jpg" ) |
| 12 |
|
| 13 |
' Fit mode |
| 14 |
' Width, fixing the destination width |
| 15 |
' Height, fixing the destination height |
| 16 |
' WidthHeight, auto-fit the destination width and height |
| 17 |
' Percent, the destination width and height is the percent of the origin |
| 18 |
' None, stretching the image to fill the destination width and height |
| 19 |
' Note: |
| 20 |
' The width and height will be invalid if you use percent fit mode, |
| 21 |
' however, the percent will be invalid if you use other fit mode. |
| 22 |
oGraphic.Fit = "None" |
| 23 |
|
| 24 |
' Destination image width |
| 25 |
oGraphic.Width = 200 |
| 26 |
|
| 27 |
' Destination image height |
| 28 |
oGraphic.Height = 200 |
| 29 |
|
| 30 |
' If you use percent fit mode, you must use decimal fraction, not integer |
| 31 |
' The following code shows that the destination is 50 percent of origin image. |
| 32 |
' oGraphic.Percent= 0.5 |
| 33 |
|
| 34 |
|
| 35 |
' Resizing image |
| 36 |
oGraphic.Resize |
| 37 |
|
| 38 |
Set oGraphic = Nothing |
| 39 |
%> |
| 40 |
|
| 41 |
<% |
| 42 |
' Show the contrastive effect |
| 43 |
Response.Write "<img src=""images/demo.jpg"" border=""0"">" |
| 44 |
Response.Write "<img src=""images/tmp/resize.jpg"" border=""0"">" |
| 45 |
%> |
| 46 |
|