How to Create a Motion Blur Effect in PHP
Looking for a way to put your images in motion? You can use the below code to call our Motion Blur API and quickly create customized motion blurs on images at scale. Each request should specify the radius, sigma, and angle (in degrees) of the motion blur.
You can use this API for free — just create a free account on our website (this supplies an API key with a limit of 800 API calls per month) and follow brief steps below to copy & paste ready-to-run PHP code examples.
First install the PHP client. Use Composer by executing this command from the command line:
composer require cloudmersive/cloudmersive_imagerecognition_api_client
Next (and last), use the below code examples to structure your request. Provide your API key in the $config line:
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: Apikey
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('Apikey', 'YOUR_API_KEY');
$apiInstance = new Swagger\Client\Api\FilterApi(
new GuzzleHttp\Client(),
$config
);
$radius = 56; // int | Radius in pixels of the blur operation; a larger radius will produce a greater blur effect
$sigma = 56; // int | Sigma, or variance, of the motion blur operation
$angle = 56; // int | Angle of the motion blur in degrees
$image_file = "/path/to/inputfile"; // \SplFileObject | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
try {
$result = $apiInstance->filterMotionBlur($radius, $sigma, $angle, $image_file);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FilterApi->filterMotionBlur: ', $e->getMessage(), PHP_EOL;
}
?>
That’s all there is to it. Easy!