thumb: only shrink larger images
[minimedit.git] / thumb / index.php
index a6b5bd7d66cce6d27560b120955a3fae695aaaa1..bd08d8841497d266a1b573d172431f96981e2b0c 100644 (file)
@@ -1,6 +1,10 @@
 <?php
 if (!$User) return;
-list ($size, $imgpath) = explode('/', ltrim($Page->path, '/'), 2);
+$imgpath = ltrim($Page->path, '/');
+if (!preg_match('{^[0-9x]+/}', $imgpath)) {
+       return;
+}
+list ($size, $imgpath) = explode('/', $imgpath, 2);
 $imgpath = preg_replace('{^(?=[0-9]+/)}', 'data/', $imgpath, 1);
 
 if (!file_exists($imgpath)) {
@@ -95,7 +99,7 @@ function mkthumb_exec($source, $target, $width, $height)
                '-interlace', 'plane', # progressive
                '-strip', '-taint', # omit metadata
                '-sampling-factor', '4:2:0', '-colorspace', 'sRGB', # half chroma
-               '-resize', "${width}x${height}",
+               '-resize', "${width}x${height}>",
                '-quality', '85%',
                $source, "jpg:$target"
        ]));