ASPPY.image

The ASPPY.image namespace exposes the powerful Python Pillow library directly to VBScript. You can resize, crop, draw, apply filters, and enhance images seamlessly.

Namespaces

ASPPY.image.Image

  • open(path) - Opens and identifies the given image file.
  • new(mode, size, [color]) - Creates a new image with the given mode ("RGB", "RGBA") and size Array(width, height).
  • ImageInstance methods: save(path), resize(Array(w, h)), crop(Array(left, top, right, bottom)), rotate(angle), convert(mode).
  • ImageInstance properties: width, height, size.

ASPPY.image.ImageDraw

  • Draw(img) - Returns a DrawInstance for drawing on the image.
  • DrawInstance methods: text(xy, text, [fill]), rectangle(box, [outline], [fill]), ellipse(box, [outline], [fill]), line(xy, [fill], [width]).

ASPPY.image.ImageFilter

  • GaussianBlur(radius) - Creates a Gaussian blur filter object to be passed into ImageInstance.filter().
  • Constants: BLUR, SHARPEN, SMOOTH, CONTOUR, EMBOSS, etc.

Sample Code

<%
Dim img, draw, filter, blurredImg
' 1. Create a new 200x200 RGB image with a blue background
Set img = ASPPY.image.Image.new("RGB", Array(200, 200), Array(0, 0, 255))

' 2. Draw a red rectangle and some text
Set draw = ASPPY.image.ImageDraw.Draw(img)

' Rectangle box: Array(Left, Top, Right, Bottom)
draw.rectangle Array(50, 50, 150, 150), Array(255, 255, 255), Array(255, 0, 0)

' Draw text at Array(X, Y)
draw.text Array(60, 90), "ASPPY Image", Array(255, 255, 255)

' 3. Apply a Gaussian Blur filter
Set blurredImg = img.filter(ASPPY.image.ImageFilter.GaussianBlur(2.0))

' 4. Save the modified image
Dim savePath
savePath = Server.MapPath("/images/output.jpg")
blurredImg.save savePath

Response.Write "Image saved successfully. Dimensions: " & blurredImg.width & "x" & blurredImg.height
%>

Resizing and Cropping Example

<%
Dim srcImg, resizedImg, croppedImg

' Open an existing image
Set srcImg = ASPPY.image.Image.open(Server.MapPath("/images/photo.jpg"))

' Resize
Set resizedImg = srcImg.resize(Array(800, 600))

' Crop center
Set croppedImg = resizedImg.crop(Array(100, 100, 700, 500))

' Save back to disk
croppedImg.save Server.MapPath("/images/photo_cropped.jpg")
%>