How to Emboss Images in PHP
Embossment is traditionally a physical process which entails creating raised surfaces on physical objects (common examples include coins or old-school soda bottles). In a two-dimensional digital space, embossment is all about emulating the physical process by creating an illusion of depth in certain areas around an image’s subjects.
Using the PHP code examples provided below, you can call our Embossment API for free and customize your output by defining the radius and sigma of the Embossment operation.
To get started, install the PHP client by executing the command below:
composer require cloudmersive/cloudmersive_imagerecognition_api_client
After that, use the remaining code examples to structure your API call. You’ll need to provide a free-tier API key in the $config line (you can get one by registering a free account on our website):
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: Apikey
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('Apikey', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Apikey', 'Bearer');
$apiInstance = new Swagger\Client\Api\FilterApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$radius = 56; // int | Radius in pixels of the emboss operation; a larger radius will produce a greater effect
$sigma = 56; // int | Sigma, or variance, of the emboss operation
$image_file = "/path/to/file.txt"; // \SplFileObject | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
try {
$result = $apiInstance->filterEmboss($radius, $sigma, $image_file);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FilterApi->filterEmboss: ', $e->getMessage(), PHP_EOL;
}
?>
All done!