Imagick API Documentation

This API allows you to perform various image manipulation actions using the PHP Imagick extension. Below, you'll find details on how to use the /imagick endpoint, including supported actions, parameters, and response structure.

Endpoint: /imagick

The /imagick endpoint accepts a JSON body with the following structure:

Request Structure

{ "images": [ { "type": "url | base64 | blank", "url": "base64_encoded_url (if type is url)", "image": "base64_encoded_image_data (if type is base64)", "actions": { "action_name": { "param1": "value", ... }, ... } } ] }

Parameters

Supported Actions

The following actions can be performed on the images. Each action is a key in the actions object, with its value being an object of parameters.

Action Description Parameters (type, default)
resizeImage Resizes the image. width (int, 100), height (int, 100)
mergeImageLayers Merges image layers (flatten). None
setImageFormat Sets the image format. format (string, e.g. "png")
setImageBackgroundColor Sets the background color. color (string, e.g. "#ffffff")
setImageCompression Sets the image compression type. type (string, e.g. "JPEG")
setImageCompressionQuality Sets the image compression quality. quality (int, e.g. 90)
annotateImage Adds text to the image. text (string), x (int, 0), y (int, 0), angle (float, 0), font (string, "Arial"), fontSize (int, 12), color (string, "black")
thumbnailImage Creates a thumbnail. width (int, 100), height (int, 100), bestFit (bool, true)
rotateImage Rotates the image. angle (float, 0)
cropImage Crops the image. x (int, 0), y (int, 0), width (int, image width), height (int, image height)
flipImage Flips the image vertically. None
flopImage Flips the image horizontally. None
blurImage Applies a blur effect. radius (float, 0), sigma (float, 1)
sharpenImage Sharpens the image. radius (float, 0), sigma (float, 1)
brightnessContrastImage Adjusts brightness and contrast. brightness (int, 0), contrast (int, 0)
modulateImage Modulates brightness, saturation, hue. brightness (int, 100), saturation (int, 100), hue (int, 100)
negateImage Inverts the image colors. gray (bool, false)
setImageType Sets the image type (e.g. grayscale). type (string, e.g. "IMGTYPE_GRAYSCALE")
sepiaToneImage Applies a sepia tone effect. threshold (float, 80)
edgeImage Detects edges in the image. radius (float, 1)
embossImage Applies an emboss effect. radius (float, 0), sigma (float, 1)
charcoalImage Simulates a charcoal drawing. radius (float, 1), sigma (float, 0.5)
oilPaintImage Simulates an oil painting effect. radius (float, 3)
solarizeImage Applies a solarization effect. threshold (float, 128)
vignetteImage Adds a vignette effect. blackPoint (float, 0), whitePoint (float, 1), x (int, 0), y (int, 0)
waveImage Applies a wave distortion. amplitude (float, 5), length (float, 10)
addNoiseImage Adds noise to the image. type (string, e.g. "NOISE_UNIFORM")
pixelate Pixelates the image. blockSize (int, 10)
ImagickDraw Initializes a drawing context for vector graphics. None
setFillColor Sets the fill color for drawing. color (string, e.g. "#000000")
setStrokeWidth Sets the stroke width for drawing. width (float, 1)
setStrokeColor Sets the stroke color for drawing. color (string, e.g. "#ffffff")
setFont Sets the font for drawing text. font (string, e.g. "Arial")
setFontSize Sets the font size for drawing text. size (int, 12)
drawText Draws text at a position. x (int, 0), y (int, 0), text (string)
drawImage Draws the vector graphics on the image. None
addImage Adds an image to the current image stack. None

Example Request

{ "images": [ { "type": "base64", "image": "iVBORw0KGgoAAAANSUhEUgAA...", "actions": { "resizeImage": { "width": 200, "height": 200 }, "rotateImage": { "angle": 90 }, "annotateImage": { "text": "Sample", "x": 10, "y": 30, "fontSize": 18, "color": "#ff0000" }, "sepiaToneImage": { "threshold": 90 } } } ] }

Example Response

{ "success": true, "data": [ "base64_encoded_image_data", "base64_encoded_image_data" ], "message": "Image processed successfully", "statusCode": 200 }
Note: Ensure that the input JSON is properly formatted.
For drawing actions, you must first initialize with ImagickDraw before using drawing-related actions.