chiark / gitweb /
m.images: display long exposure as 1.5 s instead of 3/2 s.
authorVladimír Vondruš <mosra@centrum.cz>
Mon, 11 Dec 2017 15:51:54 +0000 (16:51 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Mon, 11 Dec 2017 16:01:22 +0000 (17:01 +0100)
pelican-plugins/m/images.py
pelican-plugins/m/test/images/longexposure.jpg [new file with mode: 0644]
pelican-plugins/m/test/images/page.html
pelican-plugins/m/test/images/page.rst
pelican-plugins/m/test/test_images.py

index 2ebc16db3404e6ec73bea09f00aeab14e0b369e2..b8e1217615c1548eb1c5079ea565da54aeccc894 100644 (file)
@@ -197,7 +197,11 @@ class ImageGrid(rst.Directive):
                 if 'FNumber' in exif:
                     caption += ["F{}".format(float(float(exif['FNumber'][0])/float(exif['FNumber'][1])))]
                 if 'ExposureTime' in exif:
-                    caption += ["{}/{} s".format(exif['ExposureTime'][0], exif['ExposureTime'][1])]
+                    numerator, denominator = exif['ExposureTime']
+                    if int(numerator) > int(denominator):
+                        caption += ["{} s".format(float(numerator)/float(denominator))]
+                    else:
+                        caption += ["{}/{} s".format(numerator, denominator)]
                 if 'ISOSpeedRatings' in exif:
                     caption += ["ISO {}".format(exif['ISOSpeedRatings'])]
                 caption = ', '.join(caption)
diff --git a/pelican-plugins/m/test/images/longexposure.jpg b/pelican-plugins/m/test/images/longexposure.jpg
new file mode 100644 (file)
index 0000000..1da8acc
Binary files /dev/null and b/pelican-plugins/m/test/images/longexposure.jpg differ
index abf048f5a8c38122f495342534725fd58caf1386..3ddd6adc4426c0ff3ea554c4456618af4cb92e19 100644 (file)
@@ -85,15 +85,19 @@ Yes.</span>
 <p>Image grid with a PNG file and a JPEG with sparse EXIF data:</p>
 <div class="m-imagegrid m-container-inflate">
 <div>
-<figure style="width: 70.588%">
+<figure style="width: 54.545%">
 <a href="./tiny.png"><img src="./tiny.png" /><div>
 </div>
 </a>
 </figure>
-<figure style="width: 29.412%">
+<figure style="width: 22.727%">
 <a href="./sparseexif.jpg"><img src="./sparseexif.jpg" /><figcaption>F2.8</figcaption>
 </a>
 </figure>
+<figure style="width: 22.727%">
+<a href="./longexposure.jpg"><img src="./longexposure.jpg" /><figcaption>1.5 s</figcaption>
+</a>
+</figure>
 </div>
 </div>
 <!-- /content -->
index 13fe99aa700bbcf2a942bb8eff5790b532c06f25..273d98381919517eec1151b058c4e03ce3401f00 100644 (file)
@@ -63,3 +63,4 @@ Image grid with a PNG file and a JPEG with sparse EXIF data:
 
     {filename}/tiny.png
     {filename}/sparseexif.jpg
+    {filename}/longexposure.jpg
index 699e1f0928255efd56e0489688610a461eec56ce..84725d60fe11f190c7ba86155a0f49dec252e397 100644 (file)
@@ -31,7 +31,7 @@ class Images(PluginTestCase):
     def test(self):
         self.run_pelican({
             'PLUGINS': ['m.htmlsanity', 'm.images'],
-            'STATIC_PATHS': ['tiny.png', 'ship.jpg', 'flowers.jpg', 'sparseexif.jpg']
+            'STATIC_PATHS': ['tiny.png', 'ship.jpg', 'flowers.jpg', 'sparseexif.jpg', 'longexposure.jpg']
         })
 
         #