Create route for image resizing
This route should receive an url in get parameter (check for base64), with size parameters and send it to the image resizer and return it as a binary response image.
<?php
$resize = 'fit';
$width = 300;
$height = 300;
$gravity = 'no';
$enlarge = 1;
$extension = 'png';
$url = 'https://aboutgoods-test.ams3.digitaloceanspaces.com/aboutg-6-a184-4098-9b37-af45c3266d96/3129dd23-9f4e-4bf0-a771-9d829f94955d';
$encodedUrl = rtrim(strtr(base64_encode($url), '+/', '-_'), '=');
$key = '41626F7574676F6F6473';
$salt = '436F6D70616E79';
$keyBin = pack("H*" , $key);
if(empty($keyBin)) {
die('Key expected to be hex-encoded string');
}
$saltBin = pack("H*" , $salt);
if(empty($saltBin)) {
die('Salt expected to be hex-encoded string');
}
$path = "/{$resize}/{$width}/{$height}/{$gravity}/{$enlarge}/{$encodedUrl}.{$extension}";
$signature = rtrim(strtr(base64_encode(hash_hmac('sha256', $saltBin.$path, $keyBin, true)), '+/', '-_'), '=');
print(sprintf("/%s%s", $signature, $path));