+ if (screen_size[0] >= fixed_sizes[i][0] && screen_size[1] >= fixed_sizes[i][1]) {
+ return fixed_sizes[i];
+ }
+ }
+ return [ 80, 64 ];
+}
+
+function pick_image_size(screen_size, image_size)
+{
+ var i;
+ for (i = 0; i < fixed_sizes.length; ++i) {
+ // this is a duplicate of pr0n's resizing code, hope for no floating-point
+ // inaccuracies :-)
+ var thumbxres = fixed_sizes[i][0];
+ var thumbyres = fixed_sizes[i][1];
+ var width = image_size[0];
+ var height = image_size[1];
+
+ if (!(thumbxres >= width && thumbyres >= height)) {
+ var sfh = width / thumbxres;
+ var sfv = height / thumbyres;
+ if (sfh > sfv) {
+ width /= sfh;
+ height /= sfh;
+ } else {
+ width /= sfv;
+ height /= sfv;
+ }
+ width = Math.floor(width);
+ height = Math.floor(height);
+ }
+
+ if (screen_size[0] >= width && screen_size[1] >= height) {