author | Tero Marttila <terom@fixme.fi> |
Fri, 05 Jun 2009 23:02:47 +0300 | |
changeset 68 | 49388e9fd5fa |
parent 57 | 8d06e0283b88 |
child 70 | 67dd32adf159 |
permissions | -rw-r--r-- |
57
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
1 |
""" |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
2 |
Per-image gallery state |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
3 |
""" |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
4 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
5 |
from __future__ import with_statement |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
6 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
7 |
import filesystem, render, html |
12
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
8 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
9 |
import PIL.Image |
57
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
10 |
from lib import EXIF |
33
4943047bfcb5
merged http://pajukanta.fi/temp/degal_exif_r33.tar.bz2 patch from Japsu
terom
parents:
28
diff
changeset
|
11 |
|
57
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
12 |
class Image (filesystem.File) : |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
13 |
""" |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
14 |
An Image is a filesystem File that represents an image that can be thumbnailed, and handled. |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
15 |
""" |
44
533b7e8b5d3b
strip copyright/license boilerplate from modules, except dexif and formatbytes
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
16 |
|
57
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
17 |
def __init__ (self, node, prev) : |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
18 |
""" |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
19 |
Initialize as an Image based on the given Node, linked with the given previous node |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
20 |
""" |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
21 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
22 |
super(Image, self).__init__(node) |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
23 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
24 |
# links |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
25 |
self.prev = prev |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
26 |
self.next = None |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
27 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
28 |
# the .html file for this image |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
29 |
self.html = self.parent.subfile(self.basename + '.html') |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
30 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
31 |
# info |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
32 |
self.title = self.name |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
33 |
self.description = None |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
34 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
35 |
# lazy-loading |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
36 |
self.img = None |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
37 |
self.exif = None |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
38 |
self.metadata = None |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
39 |
self.stat_data = None |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
40 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
41 |
def load_stat (self) : |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
42 |
""" |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
43 |
Load and return the os.stat info for this file |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
44 |
""" |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
45 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
46 |
if not self.stat_data : |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
47 |
self.stat_data = self.stat() |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
48 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
49 |
return self.stat_data |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
50 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
51 |
def load_image (self) : |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
52 |
""" |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
53 |
Loads the image as a PIL.Image |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
54 |
""" |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
55 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
56 |
if not self.img : |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
57 |
# open it up |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
58 |
self.img = PIL.Image.open(self.path) |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
59 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
60 |
return self.img |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
61 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
62 |
def load_exif (self) : |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
63 |
""" |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
64 |
Loads the EXIF data for the image and returns as a dict of EXIF tag names -> values. |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
65 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
66 |
Returns None if no exif data was found |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
67 |
""" |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
68 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
69 |
if self.exif is None : |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
70 |
# load |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
71 |
with self.open('rb') as fh : |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
72 |
# XXX: details=False? |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
73 |
self.exif = EXIF.process_file(fh) |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
74 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
75 |
# empty dict -> no exif data |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
76 |
if self.exif : |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
77 |
return self.exif |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
78 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
79 |
else : |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
80 |
return None |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
81 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
82 |
def load_metadata (self) : |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
83 |
""" |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
84 |
Load and return the metadata for the image as a dictionary |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
85 |
""" |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
86 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
87 |
if not self.metadata : |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
88 |
# load stuff |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
89 |
stat = self.load_stat() |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
90 |
exif = self.load_exif() |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
91 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
92 |
# XXX: avoid having to open the image? |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
93 |
size = self.load_image().size |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
94 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
95 |
# build |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
96 |
self.metadata = dict({ |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
97 |
"File name": self.name, |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
98 |
"Resolution": "%dx%d" % size, |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
99 |
"File size": format.filesize(stat.st_size), |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
100 |
"Last modified": format.filetime(stat.st_mtime), |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
101 |
}, **dict( |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
102 |
(name, exif[tag]) for tag, name in self.config.exif_tags if exif and tag in exif |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
103 |
)) |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
104 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
105 |
return self.metadata |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
106 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
107 |
def render_image (self) : |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
108 |
""" |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
109 |
Renders new thumbnails/previews for this image. |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
110 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
111 |
Note: this does not check for the existance of the thumbs/previews subdirs! |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
112 |
""" |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
113 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
114 |
# load origional image |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
115 |
img = self.load_image() |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
116 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
117 |
# renderer to use |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
118 |
# XXX: get from elsewhere |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
119 |
render_machine = self.config.get_renderer() |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
120 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
121 |
# lazy-render both thumb and preview |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
122 |
self.thumb = render_machine.render_lazy(self |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
123 |
self.config.thumb_size, self.parent.load_thumb_dir.subnode(self.name) |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
124 |
) |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
125 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
126 |
self.preview = render_machine.render_lazy(self, |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
127 |
self.config.preview_size, self.parent.load_preview_dir.subnode(self.name) |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
128 |
) |
44
533b7e8b5d3b
strip copyright/license boilerplate from modules, except dexif and formatbytes
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
129 |
|
12
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
130 |
class Image (object) : |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
131 |
def __init__ (self, dir, name) : |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
132 |
# the image filename, e.g. DSC3948.JPG |
27
301d738b1181
fix some unicode issues, and not-alive-dirs-in-subdirs-list issues
terom
parents:
14
diff
changeset
|
133 |
self.name = unicode(name) |
12
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
134 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
135 |
# the Folder object that we are in |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
136 |
self.dir = dir |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
137 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
138 |
# the relative path from the root to us |
27
301d738b1181
fix some unicode issues, and not-alive-dirs-in-subdirs-list issues
terom
parents:
14
diff
changeset
|
139 |
self.path = dir.pathFor(self.name) |
12
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
140 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
141 |
# the basename+ext, e.g. DSCR3948, .JPG |
27
301d738b1181
fix some unicode issues, and not-alive-dirs-in-subdirs-list issues
terom
parents:
14
diff
changeset
|
142 |
self.base_name, self.ext = os.path.splitext(self.name) |
12
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
143 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
144 |
# our user-friendly title |
27
301d738b1181
fix some unicode issues, and not-alive-dirs-in-subdirs-list issues
terom
parents:
14
diff
changeset
|
145 |
self.title = self.name |
12
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
146 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
147 |
# our long-winded description |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
148 |
self.descr = '' |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
149 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
150 |
# the image before and after us, both may be None |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
151 |
self.prev = self.next = None |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
152 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
153 |
# the image-relative names for the html page, thumb and preview images |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
154 |
self.html_name = self.name + ".html" |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
155 |
self.thumb_name = utils.url_join(settings.THUMB_DIR, self.name) |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
156 |
self.preview_name = utils.url_join(settings.PREVIEW_DIR, self.name) |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
157 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
158 |
# the root-relative paths to the html page, thumb and preview images |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
159 |
self.html_path = self.dir.pathFor(self.html_name) |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
160 |
self.thumb_path = self.dir.pathFor(settings.THUMB_DIR, self.name) |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
161 |
self.preview_path = self.dir.pathFor(settings.PREVIEW_DIR, self.name) |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
162 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
163 |
# |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
164 |
# Figured out after prepare |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
165 |
# |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
166 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
167 |
# (w, h) tuple |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
168 |
self.img_size = None |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
169 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
170 |
# the ShortURL code for this image |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
171 |
self.shorturl_code = None |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
172 |
|
57
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
173 |
# EXIF data |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
174 |
self.exif_data = {} |
33
4943047bfcb5
merged http://pajukanta.fi/temp/degal_exif_r33.tar.bz2 patch from Japsu
terom
parents:
28
diff
changeset
|
175 |
|
12
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
176 |
# what to use in the rendered templates, intended to be overridden by subclasses |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
177 |
self.series_act = "add" |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
178 |
self.series_verb = "Add to" |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
179 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
180 |
def getObjInfo (self) : |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
181 |
""" |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
182 |
Metadata for shorturl2.db |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
183 |
""" |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
184 |
return 'img', self.dir.path, self.name |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
185 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
186 |
def breadcrumb (self) : |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
187 |
""" |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
188 |
Returns a [(fname, title)] list of this image's parents |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
189 |
""" |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
190 |
|
13
c229bcb1de41
image breadcrumb links back to page that said image is on
terom
parents:
12
diff
changeset
|
191 |
return self.dir.breadcrumb(forImg=self) + [(self.html_name, self.title)] |
12
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
192 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
193 |
def render (self) : |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
194 |
""" |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
195 |
Write out the .html file |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
196 |
""" |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
197 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
198 |
# stat the image file to get the filesize and mtime |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
199 |
st = os.stat(self.path) |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
200 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
201 |
self.filesize = st.st_size |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
202 |
self.timestamp = st.st_mtime |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
203 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
204 |
# open the image in PIL to get image attributes + generate thumbnails |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
205 |
img = PIL.Image.open(self.path) |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
206 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
207 |
self.img_size = img.size |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
208 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
209 |
for out_path, geom in ((self.thumb_path, settings.THUMB_GEOM), (self.preview_path, settings.PREVIEW_GEOM)) : |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
210 |
# if it doesn't exist, or it's older than the image itself, generate |
28 | 211 |
if utils.mtime(out_path) < self.timestamp : |
212 |
log.info("render [%sx%s]", geom[0], geom[1], wait=True) |
|
12
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
213 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
214 |
# XXX: is this the most efficient way to do this? It seems slow |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
215 |
out_img = img.copy() |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
216 |
out_img.thumbnail(geom, resample=True) |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
217 |
out_img.save(out_path) |
28 | 218 |
|
219 |
log.done() |
|
12
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
220 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
221 |
# look for the metadata file |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
222 |
title_path = self.dir.pathFor(self.base_name + '.txt') |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
223 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
224 |
self.title, self.descr = utils.readTitleDescr(title_path) |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
225 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
226 |
if not self.title : |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
227 |
self.title = self.name |
28 | 228 |
|
229 |
if utils.mtime(self.html_path) < self.timestamp : |
|
230 |
log.info("render %s.html", self.name) |
|
12
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
231 |
|
33
4943047bfcb5
merged http://pajukanta.fi/temp/degal_exif_r33.tar.bz2 patch from Japsu
terom
parents:
28
diff
changeset
|
232 |
# parse the exif data from the file |
4943047bfcb5
merged http://pajukanta.fi/temp/degal_exif_r33.tar.bz2 patch from Japsu
terom
parents:
28
diff
changeset
|
233 |
try : |
4943047bfcb5
merged http://pajukanta.fi/temp/degal_exif_r33.tar.bz2 patch from Japsu
terom
parents:
28
diff
changeset
|
234 |
self.exif_data = dexif.parse_exif(self.path) |
4943047bfcb5
merged http://pajukanta.fi/temp/degal_exif_r33.tar.bz2 patch from Japsu
terom
parents:
28
diff
changeset
|
235 |
except dexif.ExifError, message: |
4943047bfcb5
merged http://pajukanta.fi/temp/degal_exif_r33.tar.bz2 patch from Japsu
terom
parents:
28
diff
changeset
|
236 |
log.warning("Reading EXIF data for %s failed: %s" % (self.filename, message)) |
4943047bfcb5
merged http://pajukanta.fi/temp/degal_exif_r33.tar.bz2 patch from Japsu
terom
parents:
28
diff
changeset
|
237 |
self.exif_data = {} |
4943047bfcb5
merged http://pajukanta.fi/temp/degal_exif_r33.tar.bz2 patch from Japsu
terom
parents:
28
diff
changeset
|
238 |
|
4943047bfcb5
merged http://pajukanta.fi/temp/degal_exif_r33.tar.bz2 patch from Japsu
terom
parents:
28
diff
changeset
|
239 |
|
28 | 240 |
image_tpl.render_to(self.html_path, |
57
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
241 |
stylesheet_url = self.dir.inRoot('style.css'), |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
242 |
title = self.title, |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
243 |
breadcrumb = self.breadcrumb(), |
28 | 244 |
|
57
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
245 |
prev = self.prev, |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
246 |
next = self.next, |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
247 |
img = self, |
28 | 248 |
|
57
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
249 |
description = self.descr, |
28 | 250 |
|
57
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
251 |
filename = self.name, |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
252 |
img_size = self.img_size, |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
253 |
file_size = self.filesize, |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
254 |
timestamp = self.timestamp, |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
255 |
exif_data = self.exif_data, |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
256 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
257 |
shorturl = self.dir.inRoot('s', self.shorturl_code), |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
258 |
shorturl_code = self.shorturl_code, |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
259 |
|
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
260 |
series_url = self.dir.inRoot('series/%s/%s' % (self.series_act, self.shorturl_code)), |
8d06e0283b88
start implementing new Image stuff, tie in RenderMachine into the new Image class, assoicated config stuff
Tero Marttila <terom@fixme.fi>
parents:
44
diff
changeset
|
261 |
series_verb = self.series_verb, |
28 | 262 |
) |
12
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
263 |
|
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
264 |
def __str__ (self) : |
c2d8e9a754a1
Major code restructuring. Version is now 0.5, templates use Mako, and the code is split off into several files under lib/
terom
parents:
diff
changeset
|
265 |
return "Image `%s' in `%s'" % (self.name, self.dir.path) |
28 | 266 |