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

Utilities

Learn how to perform image transformations such as resizing, rotating, cropping, flipping, shearing, and translating images using BoxLang.

Image properties, format support, validation functions, and color reference.

Table of Contents

Image Properties

Get Image Dimensions

img = ImageNew("photo.jpg");

// Get width and height
width = img.getWidth();    // Member function
height = img.getHeight();  // Member function

// BIF syntax
width = ImageGetWidth(img);
height = ImageGetHeight(img);

writeln("Image is #width# x #height# pixels");

Check Image Type

Get Comprehensive Info

Format Support

Get Readable Formats

Get Writeable Formats

Check Format Support

Supported Formats Reference

Format
Read
Write
Notes

BMP

Bitmap, no compression. Alpha auto-composited on write.

GIF

Supports transparency, limited to 256 colors

JPEG

Lossy compression, no transparency. Alpha auto-composited on write.

PNG

Lossless, supports transparency

TIFF

High quality, suitable for archival/printing

WebP

Modern format, lossy & lossless, smaller than PNG/JPEG

WBMP

Wireless bitmap, monochrome (read-only)

Notes:

  • PNG - Best for web graphics, supports full transparency

  • JPEG - Best for photos, smaller file size

  • WebP - Modern replacement for PNG/JPEG, excellent compression. Reading works cross-platform; writing requires native library (Linux/macOS Intel supported, Apple Silicon throws a clear error).

  • GIF - Best for simple animations, limited color palette

  • TIFF - Best for archival, printing, high-quality master files

  • BMP - Uncompressed, large files, simple format

Validation Functions

IsImage()

Check if a variable contains an image object:

IsImageFile()

Check if a file is a valid image without loading it:

Validation Examples

Color Reference

Named Colors

The module supports these named colors:

Available Named Colors:

Color
Hex Value
Color
Hex Value

black

#000000

white

#FFFFFF

red

#FF0000

green

#00FF00

blue

#0000FF

cyan

#00FFFF

magenta

#FF00FF

yellow

#FFFF00

orange

#FFA500

pink

#FFC0CB

gray

#808080

darkgray

#A9A9A9

lightgray

#D3D3D3

Hex Colors

Color Format Examples

Image Information

ImageInfo() Structure

Color Model Types

Binary Operations

Get Image as Byte Array

Get Java BufferedImage

Base64 Encoding

Utility Functions Reference

Function
Purpose
Example

GetReadableImageFormats()

List readable formats

["BMP", "GIF", ...]

GetWriteableImageFormats()

List writable formats

["BMP", "GIF", ...]

ImageGetWidth(img)

Get width in pixels

1920

ImageGetHeight(img)

Get height in pixels

1080

ImageInfo(img)

Get full image info

{width: 1920, ...}

ImageGetBlob(img)

Get byte array

[binary data]

ImageGetBufferedImage(img)

Get Java BufferedImage

Java object

IsImage(var)

Check if variable is image

true/false

IsImageFile(path)

Check if file is image

true/false

Complete Utility Examples

Image File Browser

Format Converter

Image Validator

Batch Format Detection

Next Steps

Last updated

Was this helpful?