Hi,

> It is totally unclear to me how lazygal chooses the order in which pictures 
> are
> listed on the index page and linked together.  There is nothing about it in 
> the
> manpage, and the behaviour I see in practice doesn't fit any simple formula.

Okay, next version will have a better manpage.

> Here's and example.  One subdirectory of images (no EXIF date), listed in 
> mtime
> order:
> [snip]

You picture seam to have very close mtimes, and lazygal uses this to
sort the pictures. Therefore, close mtimes are considered equal.

Anyway I think that sorting according to filesystem mtime is not good,
so I'll be changing this to revert to comparing filenames to fit your
use case.

What do you think?

The patch against the development version would be the one attached.

Cheers,

Alex
diff -rN -u old-lazygal/lazygal/generators.py new-lazygal/lazygal/generators.py
--- old-lazygal/lazygal/generators.py   2008-08-18 21:18:45.000000000 +0200
+++ new-lazygal/lazygal/generators.py   2008-08-18 21:18:45.000000000 +0200
@@ -509,7 +509,7 @@
             self.add_dependency(WebalbumArchive(self))
 
     def prepare(self):
-        self.images.sort(lambda x, y: x.compare_date_taken(y))
+        self.images.sort(lambda x, y: x.compare_to_sort(y))
 
         # chain images
         previous_image = None
diff -rN -u old-lazygal/lazygal/sourcetree.py new-lazygal/lazygal/sourcetree.py
--- old-lazygal/lazygal/sourcetree.py   2008-08-18 21:18:45.000000000 +0200
+++ new-lazygal/lazygal/sourcetree.py   2008-08-18 21:18:45.000000000 +0200
@@ -101,6 +101,13 @@
         im = Image.open(img_path)
         return im.size
 
+    def has_exif_date(self):
+        exif_date = self.info().get_date()
+        if exif_date:
+            return True
+        else:
+            return False
+
     def get_date_taken(self):
         exif_date = self.info().get_date()
         if exif_date:
@@ -116,6 +123,26 @@
         delta = date1 - date2
         return int(delta)
 
+    def compare_filename(self, other_img):
+        return cmp(self.filename, other_img.filename)
+
+    def compare_no_exif_date(self, other_img):
+        # Comparison between 'no EXIF' and 'EXIF' sorts EXIF after.
+        if self.has_exif_date():
+            return 1
+        else:
+            return -1
+
+    def compare_to_sort(self, other_img):
+        if self.has_exif_date() and other_img.has_exif_date():
+            return self.compare_date_taken(other_img)
+        elif not self.has_exif_date() and not other_img.has_exif_date():
+            return self.compare_filename(other_img)
+        else:
+            # One of the picture has no EXIF date, so we arbitrary sort it
+            # before the one with EXIF.
+            return self.compare_no_exif_date(other_img)
+
 
 class Directory(File):
 
diff -rN -u old-lazygal/lazygal.1.xml new-lazygal/lazygal.1.xml
--- old-lazygal/lazygal.1.xml   2008-08-18 21:18:45.000000000 +0200
+++ new-lazygal/lazygal.1.xml   2008-08-18 21:18:45.000000000 +0200
@@ -265,6 +265,15 @@
   </refsect1>
 
   <refsect1>
+    <title>ORDER OF IMAGES</title>
+
+    <para>Images on the directory index page are sorted according to their
+    EXIF Date. Images without EXIF date are sorted before the ones that have
+    one, and are sorted according to their filename.</para>
+
+  </refsect1>
+
+  <refsect1>
     <title>THEMES</title>
 
     <para>A theme maps to a directory that contains at least the following

Reply via email to