cPanel/ImageManager
cPanel module

ImageManager

4 functions, invoked through the cpanel_uapi tool.

scope cpanel:uapi
Call any function with cpanel_uapi(service_id, module="ImageManager", function, params). Live availability depends on the cPanel features JetHost has enabled on your account — call list_cpanel_operations to see what is active.

convert_file GET#

Create image with new format

This function converts an image to a new file format.

Important:

When you disable the WebServer role, the system disables this function.

image_filestringRequired
The image file to convert, relative to the cPanel account's /home directory.
typestringRequired
The format to which to convert the images.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

converted_filestring
The new absolute filepath to the image.

create_thumbnails GET#

Create image thumbnails

This function creates thumbnails from images. The function saves the new thumbnail images in a thumbnails subdirectory inside the original directory. The system prepends thumbnail filenames with `tn_ (for example, tn_picture.jpg`).

Important:

When you disable the WebServer role, the system disables this function.

dirstringRequired
The path to the directory where the image resides. When you pass this parameter, the function creates a thumbnail directory directly below the image directory. NOTE: This parameter can use an absolute directory path or a path relative to the user's home directory.
height_percentageintegerRequired
The percentage by which to reduce the thumbnails' height.
width_percentageintegerRequired
The percentage by which to reduce the thumbnails' width.

Response — normalized as { ok, data, errors[], warnings[] }; data is an array of:

failedinteger
Whether the function failed to create the thumbnail file. Note: The function only returns this value if it doesn't create the thumbnail. 1 is the only possible value.
One of: 1
filestring
The file from which the function generated the thumbnail file. An absolute filepath.
reasonstring
The reason that the function didn't create the thumbnail file. Note: The function only returns this value if it doesn't create the thumbnail.
thumbnail_filestring
The thumbnail file that the function generated. An absolute filepath.

get_dimensions GET#

Return image dimensions

This function returns the dimensions of the image file that you specify.

Important:

When you disable the WebServer role, the system disables this function.

image_filestringRequired
The path to the file to measure. Note: Use the absolute filepath or a path relative to the user's home directory.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

heightinteger
The image's height, in pixels.
widthinteger
The image's width, in pixels.

resize_image GET#

Save resized image

This function resizes a specified image.

Important:

When you disable the WebServer role, the system disables this function.

heightintegerRequired
The height to which to set the image size.
image_filestringRequired
The name of the file to scale. Note: Use the absolute filepath or a filepath relative to the user's home directory.
widthintegerRequired
The width to which to set the image size.
save_original_asstringOptional
The path to the directory in which to save a copy the original image file. Note: If you don't pass this parameter, the function doesn't save a copy of the original image. Use the absolute filepath or a filepath relative to the user's home directory.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

The absolute filepath to the resized image.