Create image thumbnails with help of Microsoft Artificial Intelligence, and show what needed!
A thumbnail is a small representation of a full-size image. Varied devices such as phones, tablets, and PCs create a need for different user experience (UX) layouts and thumbnail sizes. Using smart cropping, this Computer Vision API feature helps solve the problem.
After uploading an image, a high quality thumbnail gets generated and the Computer Vision API algorithm analyzes the objects within the image, then crops it to fit the requirements of the “region of interest” (ROI). The output gets displayed within a special framework as seen in below illustration. The generated thumbnail can be presented in a different aspect ratio than that of the original image to accommodate a user’s needs.
The thumbnail algorithm works as follows:
composer require gevman/azure-thumbnails
$image
- full path of image$width
- thumbnail width$height
- thumbnail height$file
- full path of thumbnail$quality
- thumbnail quality$quality
- thumbnail quality$contentType
- Content-Type headerComputer Vision API key
from Microsoft Azurerequire '../vendor/autoload.php';
$generator = new \Gevman\Thumbnails\Generator('{Computer Vision API key}');
$thumb = $generator->thumbnail('/full/path/to/original.jpg', 1000, 500);
//will save thumbnail to specified path
$thumb->saveAs('/full/path/to/thumbnail.jpg', 100);
//will show thumbnail
$thumb->show();
Comments