Project

General

Profile

Feature #706 ยป maus-image-svg.txt

Jackson, Mike, 13 December 2011 12:08

 
1
# Bazaar merge directive format 2 (Bazaar 0.90)
2
# revision_id: chrisrogers1234@yahoo.co.uk-20111213123715-\
3
#   92vt8lq5cjsmmvk4
4
# target_branch: http://bazaar.launchpad.net/~michaelj-h/maus-\
5
#   apps/devel/
6
# testament_sha1: b45b620f409d98f6171b1aa91644a4a9d1032a9d
7
# timestamp: 2011-12-13 12:38:20 +0000
8
# base_revision_id: michaelj@epcc.ed.ac.uk-20111201164654-\
9
#   5ujinhq3el6qw2jn
10
# 
11
# Begin patch
12
=== modified file 'src/maus-web/maus/views.py'
13
--- src/maus-web/maus/views.py	2011-12-01 16:34:40 +0000
14
+++ src/maus-web/maus/views.py	2011-12-13 12:37:15 +0000
15
@@ -41,28 +41,36 @@
16
         {'image_name': image_name, 'image_type': image_type})
17
 
18
 def thumb(request, image):
19
-    image_path = os.path.join("raw", image)
20
+    image_width = 1000
21
+    image_size = (image_width,image_width)
22
+    rel_image_path = os.path.join("raw", image)
23
+    image_path = os.path.join(MEDIA_ROOT, rel_image_path)
24
     # Check image exists.
25
-    if not default_storage.exists(image_path): 
26
+    if not default_storage.exists(rel_image_path): 
27
         raise Http404 # Page not found.
28
     [image_name, image_type] = os.path.splitext(image)
29
     # Get thumbnail name.
30
     thumb_name = image_name + "-thumb" + ".jpg"
31
     thumb_path = os.path.join("thumbs", thumb_name)
32
     abs_thumb_path = os.path.join(MEDIA_ROOT, thumb_path)
33
-    if not default_storage.exists(thumb_path):
34
-        # Create and save to cache.
35
-        image_file = Image.open(os.path.join(MEDIA_ROOT, "raw", image))
36
-        image_file.thumbnail((200,200), Image.ANTIALIAS)
37
-        image_file.save(abs_thumb_path, "JPEG")
38
-    else:
39
+#    if not default_storage.exists(thumb_path):
40
+#       # Create and save to cache.
41
+#        image_file = Image.open(os.path.join(MEDIA_ROOT, "raw", image))
42
+#        image_file.thumbnail(image_size, Image.ANTIALIAS)
43
+#        image_file.save(abs_thumb_path, "JPEG")
44
+#    else:
45
         # Reload cached image.
46
-        image_file = Image.open(abs_thumb_path)
47
+#        image_file = Image.open(abs_thumb_path)
48
     # Create and save to cache.
49
-    image_file = Image.open(os.path.join(MEDIA_ROOT, "raw", image))
50
-    image_file.thumbnail((200,200), Image.ANTIALIAS)
51
-    image_file.save(abs_thumb_path, "JPEG")
52
-
53
+    if image_type == ".svg" or image_type == ".eps":
54
+        nu_image_path = os.path.join(MEDIA_ROOT, "thumbs", image_name + ".jpg")
55
+        convert_str = "convert %s %s" % (image_path, nu_image_path)
56
+        os.system(convert_str)
57
+        image_file = Image.open(nu_image_path)
58
+    else:
59
+        image_file = Image.open(image_path)
60
+        image_file.thumbnail(image_size, Image.ANTIALIAS)
61
+        image_file.save(abs_thumb_path, "JPEG")
62
     response = HttpResponse(mimetype="image/jpg") 
63
     image_file.save(response, "JPEG") 
64
     return response 
65

    
66
# Begin bundle
67
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWRr1HhoAAjtfgEwQWm//9373
68
3QC////wUAT49sOlV3RKe7mne3vBJQgTJpqeEDFMgepM0NEPUA2jQbUJhlTaTI00NJptU8o0D1AA
69
AANAAASJCE9TTEp7VPZT1Cm1NDT9SaMAEGgPUAEVJTan6p4U0yeSaNlAGgAaAAAABJITUepoymam
70
0KeGlNpD9KHqeobKeSND1ADSaEZ9hvltB+lNDTnTriNKQXNNnVFNJkHXFvEFTawrPfWbpO/BCL2I
71
RnNNg22Nttnbq+obNO/v2ph8bPhmxtH7fIPHb4b7ZFZwSsa25xLSNmaT7zL82Bkxk8KykHV7o2FX
72
3Yefb/cJ1R0v6HEHUKZz2Jvq49JNs92Tzmsz22ZoGe5HzqpNhcOGM1tGn0S7HK5FBwtdUMgqdxzd
73
rjbSRKPNysobmfqSLVKTqaG/xCOSn1CnrLu37t3WpUsukdofOl0DGZUIgL0mREEwollW+mF/ksQe
74
JxOJyxQDDucFLJqfToUUl5vLdq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