Commit 48e1cd1a authored by Mickaël Desfrênes's avatar Mickaël Desfrênes
Browse files

cache thumbnails

parent e7a1395d
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ import tempfile
from resources.models import File
import os.path
from typing import Union
from jama import settings


def thumb(
@@ -34,9 +35,8 @@ def thumb(
    tmp_pic_path = "{}/thumb-{}-{}-{}-{}-{}-{}-{}.jpg".format(
        tempfile.gettempdir(), sha256, angle, scale, top, right, bottom, left
    )
    # if not os.path.isfile(tmp_pic_path):
    if True:
        crop_color = [224, 224, 224]
    if not os.path.isfile(tmp_pic_path):
        crop_color = [96, 96, 96]
        img = pyvips.Image.new_from_file(pic_file.local_path())
        if angle:
            img = img.rotate(angle)
@@ -54,5 +54,7 @@ def thumb(


def test(request: HttpRequest) -> HttpResponse:
    if not settings.DEBUG:
        return HttpResponseNotFound("Not Found")
    f = File.objects.filter(file_type__mime__contains="image/").last()
    return render(request, "resources/test.html", {"hash": f.hash})