ImageNew
Syntax
ImageNew( source [, width] [, height] [, imageType] [, color] )
Arguments
source
any
Yes
The source for the image. Can be a file path, URL, BufferedImage, BoxImage, or empty string.
width
numeric
No
Width of the new image (required if creating a blank image).
height
numeric
No
Height of the new image (required if creating a blank image).
imageType
string
No
Type of image to create (e.g., "RGB", "ARGB").
color
string
No
black
Background color for a new blank image.
Returns
BoxImage
— The newly created image object.
Description
Creates a new image from a variety of sources:
If
source
is a file path or URL, loads the image from that location.If
source
is aBufferedImage
, wraps it in aBoxImage
.If
source
is aBoxImage
, returns a copy of it.If
source
is an empty string, creates a blank image using the providedwidth
,height
,imageType
, andcolor
arguments.
Example
// Create from file path
img = ImageNew( "images/photo.png" );
// Create from URL
img = ImageNew( "https://example.com/image.jpg" );
// Create blank image
img = ImageNew( "", 400, 300, "RGB", "white" );
// Copy an existing BoxImage
imgCopy = ImageNew( img );
Related BIFs
ImageCopy
ImageInfo
ImageGetWidth
ImageGetHeight
Notes
If creating a blank image,
width
andheight
are required.The
imageType
should match supported types (e.g., "RGB", "ARGB").If loading from a file or URL fails, an error is thrown.
The default color for blank images is black unless specified.
Was this helpful?