mirror of https://gitlab.com/bashrc2/epicyon
Blurhash implementation
parent
8bbdb0f9cf
commit
dba0653388
25
media.py
25
media.py
|
@ -11,6 +11,7 @@ import os
|
|||
import time
|
||||
import datetime
|
||||
import subprocess
|
||||
import random
|
||||
from random import randint
|
||||
from hashlib import sha1
|
||||
from auth import createPassword
|
||||
|
@ -28,6 +29,29 @@ from shutil import move
|
|||
from city import spoofGeolocation
|
||||
|
||||
|
||||
def _getBlurHash() -> str:
|
||||
"""You may laugh, but this is a lot less computationally intensive,
|
||||
especially on large images, while still providing some visual variety
|
||||
in the timeline
|
||||
"""
|
||||
hashes = [
|
||||
"UfGuaW01%gRi%MM{azofozo0V@xuozn#ofs.",
|
||||
"UFD]o8-;9FIU~qD%j[%M-;j[ofWB?bt7IURj",
|
||||
"UyO|v_1#im=s%y#U%OxDwRt3W9R-ogjHj[WX",
|
||||
"U96vAQt6H;WBt7ofWBa#MbWBo#j[byaze-oe",
|
||||
"UJKA.q01M|IV%LM|RjNGIVj[f6oLjrofaeof",
|
||||
"U9MPjn]?~Cxut~.PS1%1xXIo0fEer_$*^jxG",
|
||||
"UtLENXWCRjju~qayaeaz00j[ofayIVkCkCfQ",
|
||||
"UHGbeg-pbzWZ.ANI$wsQ$H-;E9W?0Nx]?FjE",
|
||||
"UcHU%#4n_ND%?bxatRWBIU%MazxtNaRjs:of",
|
||||
"ULR:TsWr~6xZofWWf6s-~6oK9eR,oes-WXNJ",
|
||||
"U77VQB-:MaMx%L%MogRkMwkCxuoIS*WYjEsl",
|
||||
"U%Nm{8R+%MxuE1t6WBNG-=RjoIt6~Vj]RkR*",
|
||||
"UCM7u;?boft7oft7ayj[~qt7WBoft7oft7Rj"
|
||||
]
|
||||
return random.choice(hashes)
|
||||
|
||||
|
||||
def _replaceSiloDomain(postJsonObject: {},
|
||||
siloDomain: str, replacementDomain: str,
|
||||
systemLanguage: str) -> None:
|
||||
|
@ -308,6 +332,7 @@ def attachMedia(baseDir: str, httpPrefix: str,
|
|||
'url': httpPrefix + '://' + domain + '/' + mediaPath
|
||||
}
|
||||
if mediaType.startswith('image/'):
|
||||
attachmentJson['blurhash'] = _getBlurHash()
|
||||
# find the dimensions of the image and add them as metadata
|
||||
attachImageWidth, attachImageHeight = \
|
||||
getImageDimensions(imageFilename)
|
||||
|
|
Loading…
Reference in New Issue