$imageLoadFromURL
Loads an image from a URL and saves it with a reference name for later use in other image manipulation functions.
Usage
$imageLoadFromURL[name;URL]
name
: A unique name you'll use to refer to this image in other$image...
functions. Choose a descriptive name like "avatar" or "background".URL
: The full URL of the image you want to load. This URL must point directly to an image file (e.g.,.png
,.jpg
,.gif
).
Example
This example creates a 300x300 image, loads the author's avatar from their profile picture, and then draws the avatar onto the newly created image.
Explanation:
$imageCreate[300;300]
: Creates a new image with dimensions 300x300 pixels.$imageLoadFromURL[avatar;$replaceText[$authorAvatar;webp;png]]
:- Loads the image from the author's avatar URL (
$authorAvatar
). $replaceText[$authorAvatar;webp;png]
replaces.webp
extensions with.png
. This is a common workaround since not all image libraries fully support.webp
and.png
is generally more compatible. This ensures a compatible image format.- Saves the loaded image with the name "avatar".
- Loads the image from the author's avatar URL (
$imageDraw[avatar;0;0;300;300]
: Draws the image named "avatar" (loaded in the previous step) onto the created image. The coordinates0;0
specify the top-left corner of where the avatar should be placed, and300;300
defines the width and height of the drawn image (effectively stretching or shrinking the avatar to fill the entire canvas).$image[$imageOutput]
: Outputs the final image.$imageOutput
is a special variable that tells the command processor to display the generated image.
Key takeaways:
- The
$imageLoadFromURL
function doesn't directly display the image. It loads it into memory for further processing with other$image...
functions. - You must provide a valid URL that points directly to an image file.
- Choose meaningful names for your loaded images; this will make your code easier to read and understand.