ASPSMARTIMAGE : DOCUMENTATION
SmartImage Object
Last modified : may 5, 2002
© 2002 Advantys. All rights reserved.

OriginalWidth
The OriginalWidth property return initial Width of the picture. This read only property return a "Long" type.

Syntax
Long OriginalWidth = .OriginalWidth

Example
<%
OriginalWidth = mySmartImage.OriginalWidth
%>

OriginalHeight
The OriginalHeight property return initial Height of the picture. This read only property return a "Long" type.

Syntax
Long OriginalHeight = .OriginalHeight

Example
<%
OriginalHeight = mySmartImage.OriginalHeight
%>

OriginalSize
The OriginalSize property return the size in bytes of the initial picture. This read only property return a "Long" type.

Syntax
Long OriginalSize = .OriginalSize

Example
<%
OriginalSize = mySmartImage.OriginalSize
%>

Width
The Width property return the new Width of the picture after a "Resample" or a "Crop". This read only property return a "Long" type.

Syntax
Long Width = .Width

Example
<%
Width = mySmartImage.Width
%>

Height
The Height property return the new Height of the picture after a "Resample" or a "Crop". This read only property return a "Long" type.

Syntax
Long Height = .Height

Example
<%
Width = mySmartImage.Height
%>

Size
The Size property return the new Size of the picture after a "Resample" or a "Crop". This read only property return a "Long" type.

Syntax
Long Size = .Size

Example
<%
Size = mySmartImage.Size
%>

Quality
The Quality property set the image quality used for the compression. This value should be included between 0 (Low Quality, High compression) and 100 (High Quality, Low Compression). This is a Read/Write property.

Syntax
.Quality = int Quality

Default value
80

Example
<%
mySmartImage.Quality=60
%>

Comment
The Comment property set a comment to be included in the new JPEG. This is a Read/Write property.

Syntax
.Comment = String Comment

Default Value
Empty string

Example
<%
mySmartImage.Comment="aspSmartImage JPEG"
%>

FontFace
Specifies font face to write text on your picture
This font should be installed on your server. If specified font is not found, a system-default font is used.
This is a Read/Write property.

Syntax
.FontFace = String FontFace

Default Value
"Arial"

Example
<%
mySmartImage.FontFace="Courier New"
%>

FontBold
Specifies if font is bold or not
This is a Read/Write property.

Syntax
.FontBold = Boolean (true|false)

Default Value
false

Example
<%
mySmartImage.FontBold=true
%>

FontColor
Use this property to define font color.
This is a Read/Write property.

Syntax
.FontColor = String FontColor

Default Value
"000000"

Example
<%
' White font
mySmartImage.FontColor="FFFFFF"

' Red font
mySmartImage.FontColor="FF0000"

' Blue font
mySmartImage.FontColor="0000FF"

' Grey font
mySmartImage.FontColor="DEDEDE"
%>

FontItalic
Specifies if font is italic or not
This is a Read/Write property.

Syntax
.FontItalic = Boolean (true|false)

Default Value
false

Example
<%
mySmartImage.FontItalic<=true
%>

FontOrientation
Specifies text rotation angle in degree (counter-clock-wise).
This is a Read/Write property.

Syntax
.FontOrientation = int rotation angle

Default Value
0 (horizontal)

Example
<%
mySmartImage.FontOrientation = 45
%>

FontSize
Specifies font size in pixels.
This is a Read/Write property.

Syntax
.FontSize = int FontSize

Default Value
12

Example
<%
mySmartImage.FontSize = 24
%>

FontUnderline
Specifies if font is underline.
This is a Read/Write property.

Syntax
.FontUnderline = Boolean (true|falase)

Default Value
false

Example
<%
mySmartImage.FontUnderline = false
%>

FontCharset
Use this property when you want to add text in a language other than US ASCII.
Allowed values are :
  • ANSI_CHARSET = 0
  • DEFAULT_CHARSET = 1
  • SYMBOL_CHARSET = 2
  • MAC_CHARSET = 77
  • SHIFTJIS_CHARSET = 128
  • HANGEUL_CHARSET = 129
  • JOHAB_CHARSET = 130
  • GB2313_CHARSET = 134
  • CHINESEBIG5_CHARSET = 136
  • GREEK_CHARSET = 161
  • TURKISH_CHARSET = 162
  • VIETNAMESE_CHARSET = 163
  • HEBREW_CHARSET = 177
  • ARABIC_CHARSET = 178
  • BALTIC_CHARSET = 186
  • RUSSIAN_CHARSET = 204
  • THAI_CHARSET = 222
  • EE_CHARSET = 238
  • OEM_CHARSET = 255
This is a Read/Write property.

Syntax
.FontCharset = int Charset

Default Value
0 (Ansi charset)

Example
<%
' Add chinese text
mySmartImage.FontCharset= 136
mySmartImage.addText "ªª¦Ï¤H",0,0
%>

OpenFile
The OpenFile method open a JPEG/GIF/BMP from a file. The path can be a virtual or a physical path.
This method or OpenBinary is required.

Syntax
.OpenFile(String FileName)

Parameter
FileName is the image source file.

Example
<%
' From a JPEG file (physical path)
mySmartImage.OpenFile "D:\Inetpub\wwwroot\images\sample.jpg"

' From a JPEG file (virtual path)
mySmartImage.OpenFile "/images/sample.jpg"
%>

SaveFile
The SaveFile method save the updated image in a new Filename.
The path can be a virtual or a physical path.

Syntax
.SaveFile([String FileName])

Parameter
Filename is an optional parameter, it's the name of the file to save.
If Filename is empty, the Filename used with OpenFile will be use.
If the picture was open with OpenBinary, Filename is Required.

Example
<%
' Save (physical path)
mySmartImage.SaveFile "D:\Inetpub\wwwroot\images\sample.jpg"

' save (virtual path)
mySmartImage.SaveFile "/images/sample.jpg"
%>

OpenBinary
The OpenBinary method open a image from a bytes array.

Syntax
.OpenBinary Bytes myArray()

Parameter
myArray is a Bytes array including a JPEG,GIF or BMP.

Example
<%
' Openinng a JPEG Bytes array.
mySmartImage.OpenBinary myJPEG()

' Openning a JPEG Bytes array from a Database field.
mySmartImage.OpenBinary(oRs("IMAGE").Value) %>

SaveBinary
The SaveBinary method save the picture in a Bytes array (JPEG Format).

Syntax
.SaveBinary Bytes myArray()

Parameter
myArray is a Bytes array returned containing the JPEG.

Example
<%
' Saving an array including the JPEG
mySmartImage.SaveBinary myJPEG()
%>

Download
The Download method is used to download the updated JPEG.

Syntax
.Download [NewFileName, ContentType, ContentDisposition]

Parameter
NewFileName define the default filename in the save dialog box.
ContentType is the mime type, if an application recognize it the browser will open the application instead of open the "Save as" dialog box.
ContentDisposition contains the string of the Content Disposition Hearders for the MIME Type.
    "attachment" force the browser to ask to Open or Save the file
    "inline" open the picture in the browser

Example
<%
' Download with propmpt
mySmartImage.Download  "myNewName.txt", "application/x-zip-compressed","attachment"

' Download and open in the browser
mySmartImage.Download  "myNewName.txt", "application/x-zip-compressed","inline"
%>

Resample
Resample the image.

Syntax
.Resample NewWidth, NewHeight

Parameter
NewWidth define the new Width.
NewHeight define the new Height.
If one of the two value is set to 0 then the Resample will be proportionnal.

Example
<%
' JPEG Resample with NewWidth et NewHeight
mySmartImage.Resample  800, 600

' Proportionnal Resample
mySmartImage.Resample  800, 0
%>

Crop
Crop the image.

Syntax
.Crop x1, y1, x2, y2

Parameter
x1 and Y1 defines the start point.
x2 and y2 defines the end point.
if x2 or Y2 are greater than the original size, the size of the original picture will be used.

Exemple
<%
' Crop Imager
mySmartImage.Crop  150, 50, 400, 500
%>

Sharpen
Apply a Sharpen filter to the picture.

Syntax
.Sharpen

Exemple
<%
' Sharpen filter
mySmartImage.Sharpen 
%>

Gamma
Used for Gamma Correction.

Syntax
.Gamma gRed, gGreen, gBlue

Parameter
gRed, gGreen et gBlue are factor to apply.
These values should be included in 0 and 255

Example
<%
' Red and Green Gamma Correction
mySmartImage.Gamma  0.5, 1, 2.5
%>

Blur
Blur the picture

Syntax
.Blur

Example
<%
' Blur Effect
mySmartImage.Blur 
%>

GreyScale
Convert picture colors to Grey scale

Syntax
.GreyScale

Example
<%
' Convert image to GreyScale
mySmartImage.GreyScale 
%>

Negative
Return the negative of the picture

Syntax
.Negative

Example
<%
' Negative
mySmartImage.Negative 
%>

AddImage
Add another image on current image
You can add opaque image (just paste new image) or define a transparent color (i.e. transparent background)

Syntax
.AddImage ImageFile, PosX, PosY, Optional TransparentColor

Parameter
ImageFile is the image source file. (physical or relative)
PosX and PosY are coordinates where you want to copy image.
For PosX, allowed values are :
  • Any coordinates values
  • "LEFT"
  • "CENTER"
  • "RIGHT"
For PosY, allowed values are :
  • Any coordinates values
  • "TOP"
  • "CENTER"
  • "BOTTOM"
TransparentColor specifies color to remove from picture to Add
If not specified, image will be added without modifications.
use HTML color's coding conventions

Example
<%
' Add image (No modifications, relative path, align bottom right)
mySmartImage.AddImage  "/images/logo.jpg", "RIGHT", "BOTTOM"

' Add image (Remove white background, physical path, align top left)
mySmartImage.AddImage  "d:\inetpub\wwwroot\aspsmartImage\images\logo.jpg", "TOP", "LEFT","FFFFFF"

' Add image (Remove white background, physical path, manual position)
mySmartImage.AddImage  "d:\inetpub\wwwroot\aspsmartImage\images\logo.jpg", 50, 30,"FFFFFF"
%>

AddText
Write text on your picture

Syntax
.AddText strText, PosX, PosY

Parameter
strText is the text you want to add
PosX and PosY are coordinates where you want to add text.
For PosX, allowed values are :
  • Any coordinates values
  • "LEFT"
  • "CENTER"
  • "RIGHT"
For PosY, allowed values are :
  • Any coordinates values
  • "TOP"
  • "CENTER"
  • "BOTTOM"

Example
<%
' Add Text (Bold, Italic, center, Arial, white)
mySmartImage.FontFace = "Arial"
mySmartImage.FontBold = true
mySmartImage.FontItalic = true
mySmartImage.FontColor = "FFFFFF"
mySmartImage.AddText  "Advantys", "CENTER", "CENTER"

' Add Text (Underline, anywhere, Arial, Blue, Orientation)
mySmartImage.FontFace = "Arial"
mySmartImage.FontUnderline = true
mySmartImage.FontColor = "0000FF"
mySmartImage.FontOrienation = 45
mySmartImage.AddText  "Advantys", 20, 20

%>

Flip
Perform a flip on your picture

Syntax
.Flip

Example
<%
' Flip
mySmartImage.Flip 
%>

Mirror
Return a mirror of your picture

Syntax
.Mirror

Example
<%
' Mirror
mySmartImage.Mirror 
%>

RotateLeft
Perform a left rotation of 90°

Syntax
.RotateLeft

Example
<%
' Left rotation of 90°
mySmartImage.RotateLeft 

' Left rotation of 180°
mySmartImage.RotateLeft 
mySmartImage.RotateLeft 
%>

RotateRight
Perform a right rotation of 90°

Syntax
.RotateRight

Example
<%
' Right rotation of 90°
mySmartImage.RotateRight 

' Right rotation of 180°
mySmartImage.RotateRight 
mySmartImage.RotateRight 
%>

© 2001 Advantys. All rights reserved.