Moodle PHP Documentation 5.0
Moodle 5.0.1+ (Build: 20250711) (61af040cd5f)
core_ai\ai_image Class Reference

Public Member Functions

 __construct (private string string $imagepath,)
 Constructor for the image processing class.
 
 add_watermark (string $watermark='', array $options=[], array $pos=[10, 10],)
 Add watermark to image.
 
 save (string $newpath='')
 Save image.
 

Constructor & Destructor Documentation

◆ __construct()

core_ai\ai_image::__construct ( private string string $imagepath)

Constructor for the image processing class.

Initializes the class with the provided image path, setting up the image object and its properties. The constructor checks if the GD library functions for PNG and JPEG are available, ensures the image file exists and is readable, and then creates an image resource object based on the file type (JPEG, PNG, or GIF).

Parameters
string$imagepathThe path to the image file.
Parameters
$imagepathImage path.

Member Function Documentation

◆ add_watermark()

core_ai\ai_image::add_watermark ( string $watermark = '',
array $options = [],
array $pos = [10, 10] )

Add watermark to image.

Parameters
string$watermarkWatermark text.
array$optionsWatermark options.
array$posWatermark position.
Return values
$this

◆ save()

core_ai\ai_image::save ( string $newpath = '')

Save image.

Parameters
string$newpathNew path to save image.
Return values
boolWhether the save was successful

The documentation for this class was generated from the following file: