Getting Started
Getting started guide for image manipulation in BoxLang.
This guide will help you get up and running with image manipulation in BoxLang.
Table of Contents
Creating Images
There are several ways to create or load images in BoxLang:
From a File Path
// Using ImageRead()
img = ImageRead("path/to/image.jpg");
// Using ImageNew() - recommended
img = ImageNew("path/to/image.jpg");From a URL
Create a Blank Canvas
From Base64 String
From Java BufferedImage
Reading Images
ImageRead() vs ImageNew()
Both functions read images, but ImageNew() is more versatile:
Supported Source Types
Basic Operations
Get Image Information
Check Image Properties
Get Supported Formats
Method Chaining
One of the most powerful features is method chaining with BoxImage:
Traditional BIF Approach
Fluent BoxImage Approach (Recommended)
Why Method Chaining?
Benefits:
Cleaner Code - More readable and concise
Less Variables - No need to store intermediate results
Natural Flow - Operations flow from left to right, top to bottom
IDE Support - Better autocomplete and IntelliSense
Immutable Operations - Each method returns the modified image
Mixing Approaches
You can mix BIF and member function syntax:
Saving Images
Write to File
Convert to Base64
Get as Byte Array
Get Java BufferedImage
Working with BoxImage
The BoxImage class is a fluent wrapper that makes image manipulation intuitive and powerful.
Creating BoxImage Instances
BoxImage is Mutable and Chainable
Copying Images
Complete Example
Quick Reference
Essential BIFs
ImageNew()
Create/load image
ImageNew("photo.jpg")
ImageRead()
Load from file
ImageRead("photo.jpg")
ImageWrite()
Save to file
ImageWrite(img, "out.jpg")
ImageInfo()
Get image details
ImageInfo(img)
ImageGetWidth()
Get width
ImageGetWidth(img)
ImageGetHeight()
Get height
ImageGetHeight(img)
IsImage()
Check if image
IsImage(img)
IsImageFile()
Check if file is image
IsImageFile("photo.jpg")
Essential Member Functions
Next Steps
Now that you understand the basics, explore more advanced topics:
Transformations - Resize, rotate, crop, flip
Filters & Effects - Blur, sharpen, overlay
Drawing - Draw shapes, lines, and text
Metadata - Read EXIF and IPTC data
Advanced Examples - Real-world use cases
Last updated
Was this helpful?
