Implement generating "thumbnails"

This commit is contained in:
Kumi 2023-10-30 13:51:59 +01:00
parent 74a5980cd5
commit 6e23793588
Signed by: kumi
GPG key ID: ECBCC9082395383F
5 changed files with 15 additions and 6459 deletions

File diff suppressed because it is too large Load diff

View file

@ -155,7 +155,7 @@ function finishcard(jobid, title, video) {
imgurl = $(this).attr("src"); imgurl = $(this).attr("src");
pannellum.viewer("panorama", { pannellum.viewer("panorama", {
type: "equirectangular", type: "equirectangular",
panorama: imgurl, panorama: imgurl + "/3840/1920/",
autoLoad: true, autoLoad: true,
}); });
$("#panoramaModal").modal("show"); $("#panoramaModal").modal("show");

View file

@ -5,7 +5,6 @@
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="{% static "dist/css/bootstrap.min.css" %}" type="text/css"> <link rel="stylesheet" href="{% static "dist/css/bootstrap.min.css" %}" type="text/css">
<link rel="stylesheet" href="{% static "dist/css/theme.css" %}" type="text/css">
<link rel="stylesheet" href="{% static "dist/css/pannellum.css" %}" type="text/css"> <link rel="stylesheet" href="{% static "dist/css/pannellum.css" %}" type="text/css">
<link rel="icon" type="image/png" href="{% static "img/favicon.png" %}"> <link rel="icon" type="image/png" href="{% static "img/favicon.png" %}">
<title>Panorama Image Export</title> <title>Panorama Image Export</title>
@ -132,7 +131,6 @@
<div <div
class="modal fade" class="modal fade"
id="panoramaModal" id="panoramaModal"
tabindex="-1"
role="dialog" role="dialog"
aria-hidden="true" aria-hidden="true"
> >

View file

@ -12,4 +12,5 @@ urlpatterns = [
path('result/<uuid:id>', ConversionResultView.as_view(), name='conversion_result'), path('result/<uuid:id>', ConversionResultView.as_view(), name='conversion_result'),
path('retry/<uuid:id>', ConversionRetryView.as_view(), name='conversion_retry'), path('retry/<uuid:id>', ConversionRetryView.as_view(), name='conversion_retry'),
path('download/<uuid:id>', ConversionDownloadView.as_view(), name='conversion_download'), path('download/<uuid:id>', ConversionDownloadView.as_view(), name='conversion_download'),
path('download/<uuid:id>/<int:width>/<int:height>/', ConversionDownloadView.as_view(), name='conversion_download_resized'),
] ]

View file

@ -6,6 +6,8 @@ from django.utils.decorators import method_decorator
from pix360core.models import Conversion, ConversionStatus from pix360core.models import Conversion, ConversionStatus
import PIL.Image
class ConverterView(LoginRequiredMixin, TemplateView): class ConverterView(LoginRequiredMixin, TemplateView):
"""View for the converter """View for the converter
@ -168,8 +170,18 @@ class ConversionDownloadView(LoginRequiredMixin, View):
'error': 'Conversion not done' 'error': 'Conversion not done'
}, status=404) }, status=404)
content = file.file.read() if "width" in kwargs:
width = int(kwargs['width'])
height = int(kwargs['height'])
PIL.Image.MAX_IMAGE_PIXELS = None
image = PIL.Image.open(file.file)
image.thumbnail((width, height))
image = image.convert('RGB')
response = HttpResponse(content_type="image/jpeg")
image.save(response, "JPEG")
return response
content = file.file.read()
response = HttpResponse(content, content_type=file.mime_type) response = HttpResponse(content, content_type=file.mime_type)
response['Content-Disposition'] = f'attachment; filename="{conversion.get_result_filename()}"' response['Content-Disposition'] = f'attachment; filename="{conversion.get_result_filename()}"'
return response return response