Image

This class intends to help people use the Imager in an easy way.  Imager brings some very useful image manipulations like resizing, stretching, rotating to asp.  Then the result can be used directly from the memory or saved to the hard drive.  You can also use it to retrieve image properties like width, height.

Requirements

  • CrazyBeavers Imager Resizer dll (Imager.dll)

About

Summary
This class intends to help people use the Imager in an easy way.
This should be the URI to Imager.dll including http:// etc.
Full path to the image.
Target width.
Target height.
Target compression.
Output format.
Original width.
Original height.
Use the autorotate function?
Use the whitespace function?
6 letter HEX color code used for whitespace/rotation functions.
The amount of degrees to rotate the image.
Extract EXIF data?
Return binary dat?
Force the creation of a new file in the cache?
Append the current querystring to the dll?
Error code from the query.
Error description.
Xml
XML Dom object which holds the returned xml.
go
Executes the request to the application to retrieve the XML data.
Saves the image to a path specified by path.
Extract EXIF(EXchangeable Image Format) data from the Xml.
Extract binary data from the Xml.
Extract MimeType from the Xml.
Extract filename from the imageinfo in Xml.

Properties

imagerUri

This should be the URI to Imager.dll including http:// etc.

Contains

(string) URI

image

Full path to the image.

Contains

(string) Physical path

width

Target width.

Contains

(int) Width

height

Target height.

Contains

(int) Height

compression

Target compression.

Contains

(int) Compression

output

Output format.

Contains

(string) .jpg .gif .png and .tga.  Note that it won’t work without the dot at start.

originalWidth

Original width.  This can be retrieved with ProcessBinary=false.

Contains

(int) Width

originalHeight

Original height.  This can be retrieved with ProcessBinary=false.

Contains

(int) Height

autoRotate

Use the autorotate function?

Contains

(bool) Defaults to true

whitespace

Use the whitespace function?

Contains

(bool) Defaults to false

bgColor

6 letter HEX color code used for whitespace/rotation functions.

Contains

(string) Defaults to an empty string

rotation

The amount of degrees to rotate the image.

Contains

(int) Defaults to 0

processExif

Extract EXIF data?

Contains

(bool) Defaults to true

processBinary

Return binary dat?

Contains

(bool) Defaults to true

forceNewCache

Force the creation of a new file in the cache?

Contains

(bool) Defaults to false

useQueryString

Append the current querystring to the dll?

Contains

(bool) Defaults to true

errorCode

Error code from the query.

Contains

(int) Default is 0 which means no error

errorText

Error description.

Returns

(string) Error description

Xml

XML Dom object which holds the returned xml.

Returns

(xml object) XML

Functions

go

public sub go()

Executes the request to the application to retrieve the XML data.

saveToFile

public function saveToFile( path,
overwrite )

Saves the image to a path specified by path.

Parameters

path Path to write the file
overwrite Overwrite true|false

Returns

true if the save was successful
false otherwise

Example

dim oImage
set oImage = new Image
oImage.imagerUri = "http://localhost/cgi-bin/Imager.dll"
oImage.image = Server.mapPath("image.png")
oImage.width = 88
oImage.height = 88
oImage.compression = 88
oImage.output = ".jpg"
oImage.whitespace = true
oImage.bgColor = "FFFFFF"
oImage.rotation = 15
call oImage.go()
if(oImage.ErrorCode <> 0) then
    Response.write("<strong>Error:</strong> " & oImage.errorText)
    Response.end
end if
if(not oImage.saveToFile(Server.mapPath("saved/image.jpg"), true)) then
    Response.write(oImage.errorText)
    Response.end
else
    Response.write("Saved")
end if
set nothing

getExif

public function getExif()

Extract EXIF(EXchangeable Image Format) data from the Xml.

Returns

(scripting.dictionary) With the extracted EXIF data

Example

dim oImage, Exif, sItem
set oImage = new Image
oImage.imagerUri = "http://localhost/cgi-bin/Imager.dll"
oImage.image = Server.mapPath("image.png")
call oImage.go()
if(oImage.errorCode <> 0) then
    Response.write("<strong>Error:</strong> " & oImage.errorText)
    Response.end
end if
set Exif = oImage.getEXIF()
for each sItem in Exif
    Response.write(sItem & " : " & Exif.item(sItem) & "<br />")
next
set Exif = nothing
set oImage = nothing

getBinary

public function getBinary()

Extract binary data from the Xml.

Returns

(string) With the image binary data

getMime

public function getMime()

Extract MimeType from the Xml.

Returns

(string) Mimetype of the image

Example

dim oImage
set oImage = new Image
oImage.imagerUri = "http://localhost/cgi-bin/Imager.dll"
oImage.image = Server.mapPath("image.png")
call oImage.go()
if(oImage.errorCode <> 0) then
    Response.write("<strong>Error:</strong> " & oImage.errorText)
    Response.end
end if
Response.write(oImage.getMime())
set oImage = nothing

getFilename

public function getFilename()

Extract filename from the imageinfo in Xml.

Returns

(string) Filename of the image

Example

dim oImage
set oImage = new Image
oImage.imagerUri = "http://localhost/cgi-bin/Imager.dll"
oImage.image = Server.mapPath("image.png")
call oImage.go()
if(oImage.errorCode <> 0) then
    Response.write("<strong>Error:</strong> " & oImage.errorText)
    Response.end
end if
Response.write(oImage.getFilename())
set oImage = nothing
public sub go()
Executes the request to the application to retrieve the XML data.
public function saveToFile( path,
overwrite )
Saves the image to a path specified by path.
public function getExif()
Extract EXIF(EXchangeable Image Format) data from the Xml.
public function getBinary()
Extract binary data from the Xml.
public function getMime()
Extract MimeType from the Xml.
public function getFilename()
Extract filename from the imageinfo in Xml.