For the complete documentation index, see llms.txt. This page is also available as Markdown.

Reference

Comprehensive reference for all image manipulation functions in BoxLang.

Complete alphabetical reference for all image manipulation Built-In Functions (BIFs).

Fluent Builder

The BoxLang Image Manipulation module provides a modern, fluent API through the BoxImage class. This chainable interface makes image manipulation code more readable and maintainable.

🔄 Quick Reference: BIF vs Fluent API

Here's how common BIF patterns translate to the modern Fluent API:

BIF Approach
Fluent API Equivalent

ImageNew("photo.jpg")

ImageNew("photo.jpg")

ImageResize(img, 800, 600)

img.resize(800, 600)

ImageScaleToFit(img, 400)

img.scaleToFit(400)

ImageCrop(img, 10, 10, 200, 200)

img.crop(10, 10, 200, 200)

ImageRotate(img, 90)

img.rotate(90)

ImageFlip(img, "horizontal")

img.flip("horizontal")

ImageSplitGrid(img, 4, 3)

img.splitGrid(4, 3)

ImageAddBorder(img, 5, "black")

img.addBorder(5, "black")

ImageSetDrawingColor(img, "red")

img.setDrawingColor("red")

ImageDrawText(img, "Hello", 10, 50)

img.drawText("Hello", 10, 50)

ImageBlur(img, 3)

img.blur(3)

ImageSharpen(img, 0.5)

img.sharpen(0.5)

ImageGrayScale(img)

img.grayScale()

ImageNegative(img)

img.negative()

ImageWrite(img, "output.jpg")

img.write("output.jpg")

ImageWriteBase64(img)

img.toBase64String()

ImageGetWidth(img)

img.getWidth()

ImageGetHeight(img)

img.getHeight()

Chaining Example

BIF Approach - Verbose and Procedural:

Fluent API - Concise and Chainable:


📋 Method Categories

🎨 Creation & Loading

  • Image() / ImageNew() - Create/load images from file, URL, base64, or create blank canvas

  • ImageReadBase64() - Load image from base64 string

✂️ Transformations

  • resize() - Resize to specific dimensions

  • scaleToFit() - Scale proportionally to fit within bounds

  • crop() - Extract a rectangular region

  • rotate() - Rotate by angle

  • flip() / transpose() - Flip horizontally/vertically/diagonally, or rotate in 90° increments

  • shear() - Apply shear transformation

  • splitGrid() - Split image into a grid of tiles

🎨 Effects & Filters

  • blur() - Apply blur effect

  • sharpen() - Sharpen the image

  • grayScale() - Convert to grayscale

  • negative() - Create negative

  • overlay() - Overlay another image

  • paste() - Paste image at position

🖌️ Drawing

  • setDrawingColor() - Set drawing color

  • setDrawingStroke() - Set stroke style

  • setDrawingTransparency() - Set transparency

  • setAntiAliasing() - Enable/disable anti-aliasing

  • setBackgroundColor() - Set background color

  • drawText() - Draw text

  • drawLine() - Draw line

  • drawRect() - Draw rectangle

  • drawRoundRect() - Draw rounded rectangle

  • drawOval() - Draw oval/circle

  • drawArc() - Draw arc

  • drawPoint() - Draw point

  • clearRect() - Clear rectangle area

🎀 Decorations

  • addBorder() - Add border around image

💾 Output

  • write() - Write to file (format auto-detected from extension)

  • toBase64String() - Export as base64 string (format auto-detected, overridable)

  • getBlob() - Get raw byte array

  • getBufferedImage() - Get Java BufferedImage

ℹ️ Information

  • getWidth() - Get image width

  • getHeight() - Get image height

  • info() - Get comprehensive image info

  • getExifMetadata() / getExifTag() - Read EXIF metadata

  • getIPTCMetadata() / getIPTCTag() - Read IPTC metadata

⚡ Utilities (BIF only)

  • ImageGenerateCaptcha() - Generate CAPTCHA images with configurable difficulty

  • ImageWriteToBrowser() - Stream image to HTTP response

  • GetReadableImageFormats() / GetWriteableImageFormats() - List supported formats (includes WebP, GIF, BMP, TIFF)


🚀 Complete Example

Here's a real-world example showing the power of method chaining:

Last updated

Was this helpful?