From 8a9ea4664c01f104436cfc89119f7429050841dd Mon Sep 17 00:00:00 2001 From: Daniel Quinn Date: Sat, 5 Mar 2016 02:15:26 +0000 Subject: [PATCH] Cleaned up the thumbnails by switching to .png --- src/documents/migrations/0012_auto_20160305_0040.py | 9 +++++---- src/documents/models.py | 2 +- src/documents/views.py | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/documents/migrations/0012_auto_20160305_0040.py b/src/documents/migrations/0012_auto_20160305_0040.py index e42c6cde5..876c2c68e 100644 --- a/src/documents/migrations/0012_auto_20160305_0040.py +++ b/src/documents/migrations/0012_auto_20160305_0040.py @@ -65,17 +65,18 @@ def move_documents_and_create_thumbnails(apps, schema_editor): subprocess.Popen(( settings.CONVERT_BINARY, - "-scale", "500x500", + "-scale", "500x5000", + "-alpha", "remove", orig_target, - os.path.join(thumb_temp, "convert-%04d.jpg") + os.path.join(thumb_temp, "convert-%04d.png") )).wait() - thumb_source = os.path.join(thumb_temp, "convert-0000.jpg") + thumb_source = os.path.join(thumb_temp, "convert-0000.png") thumb_target = os.path.join( settings.MEDIA_ROOT, "documents", "thumbnails", - re.sub(r"(\d+)\.\w+(\.gpg)", "\\1.jpg\\2", f) + re.sub(r"(\d+)\.\w+(\.gpg)", "\\1.png\\2", f) ) with open(thumb_source, "rb") as unencrypted: with open(thumb_target, "wb") as encrypted: diff --git a/src/documents/models.py b/src/documents/models.py index a3ffb8a74..b8baea7f8 100644 --- a/src/documents/models.py +++ b/src/documents/models.py @@ -193,7 +193,7 @@ class Document(models.Model): settings.MEDIA_ROOT, "documents", "thumbnails", - "{:07}.jpg.gpg".format(self.pk) + "{:07}.png.gpg".format(self.pk) ) @property diff --git a/src/documents/views.py b/src/documents/views.py index 4a4a060bf..1dc23aa4f 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -29,7 +29,7 @@ class IndexView(TemplateView): return TemplateView.get_context_data(self, **kwargs) -class FetchView(LoginRequiredMixin, DetailView): +class FetchView(DetailView): model = Document @@ -48,8 +48,8 @@ class FetchView(LoginRequiredMixin, DetailView): if self.kwargs["kind"] == "thumb": return HttpResponse( - GnuPG.decrypted(self.object.thumb_file), - content_type=content_types[Document.TYPE_JPG] + GnuPG.decrypted(self.object.thumbnail_file), + content_type=content_types[Document.TYPE_PNG] ) response = HttpResponse(