PHP code example of srwiez / thumbhash
1. Go to this page and download the library: Download srwiez/thumbhash library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
srwiez / thumbhash example snippets
use Thumbhash\Thumbhash;
$content = file_get_contents($url);
list($width, $height, $pixels) = extract_size_and_pixels_with_imagick($content);
$hash = Thumbhash::RGBAToHash($width, $height, $pixels);
$key = Thumbhash::convertHashToString($hash); // You can store this in your database as a string
$url = Thumbhash::toDataURL($hash);
echo '<img src="' . $url . '" />';