fix webp
This commit is contained in:
parent
c2230db4c9
commit
9eae0a8eee
1 changed files with 8 additions and 3 deletions
|
@ -79,7 +79,7 @@ class Cache {
|
|||
$name = strtolower($name);
|
||||
|
||||
$ext = substr($name, strrpos($name, ".") + 1);
|
||||
if ($skipExtensionCheck || strtolower($ext) == "jpg" || strtolower($ext) == "jpeg" || strtolower($ext) == "png") {
|
||||
if ($skipExtensionCheck || strtolower($ext) == "jpg" || strtolower($ext) == "jpeg" || strtolower($ext) == "png" || strtolower($ext) == "webp"){
|
||||
$size = strlen($data);
|
||||
$img = new Imagick();
|
||||
$img->readImageBlob($data);
|
||||
|
@ -90,9 +90,10 @@ class Cache {
|
|||
$name = str_replace("." . $ext, ".webp", strtolower($name));
|
||||
|
||||
$cacheFile = PUBLIC_CACHE_DIR . "/" . $name;
|
||||
|
||||
$blurhash = self::generateBlurHash($cacheFile, $img, $skipExtensionCheck);
|
||||
|
||||
$resourceSql = "INSERT INTO `resources` (`name`, `type`, `blurhash`, `url`, `width`, `height`, `hasBeenProcessed`, `modified`)
|
||||
$resourceSql = "INSERT OR REPLACE INTO `resources` (`name`, `type`, `blurhash`, `url`, `width`, `height`, `hasBeenProcessed`, `modified`)
|
||||
VALUES (:name,:type,:blurhash,:url,:width,:height,1,strftime('%Y-%m-%d %H:%M:%S','now'))";
|
||||
|
||||
$db = new Database();
|
||||
|
@ -119,7 +120,7 @@ class Cache {
|
|||
|
||||
// For now don't transfer file if its generated name exists
|
||||
if (file_exists($cacheFile)) {
|
||||
Logger::log("Public cache file " . $name . " already exists", Logger::INFO, "Cache");
|
||||
//Logger::log("Public cache file " . $name . " already exists", Logger::INFO, "Cache");
|
||||
return PUBLIC_CACHE_URL . "/" . $name;
|
||||
}
|
||||
|
||||
|
@ -177,6 +178,10 @@ class Cache {
|
|||
|
||||
public static function getBlurHashImage($blurhash,$width = 269, $height = 173) {
|
||||
|
||||
if (empty($blurhash)) {
|
||||
return "data:image/jpg;base64,/9j/7gAhQWRvYmUAZIAAAAABAwAQAwIDBgAAAAAAAAAAAAAAAP/bAIQAEg4ODhAOFRAQFR4TERMeIxoVFRojIhcXFxcXIhEMDAwMDAwRDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAEUExMWGRYbFxcbFA4ODhQUDg4ODhQRDAwMDAwREQwMDAwMDBEMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM/8IAEQgAAwAEAwEiAAIRAQMRAf/EAF4AAQEBAAAAAAAAAAAAAAAAAAAEBwEBAAAAAAAAAAAAAAAAAAAABBABAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAABIBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQECEQMRAAAAsZ0Kj//aAAgBAgABBQB//9oACAEDAAEFAH//2gAIAQEAAQUAf//aAAgBAgIGPwB//9oACAEDAgY/AH//2gAIAQEBBj8Af//Z";
|
||||
}
|
||||
|
||||
$hash = \kornrunner\Blurhash\Blurhash::decode($blurhash, $width, $height);
|
||||
|
||||
$img = new Imagick();
|
||||
|
|
Loading…
Reference in a new issue