+/* load and scale image */
+static Imlib_Image
+loadimage(const char *file, int size)
+{
+ Imlib_Image image;
+ int width;
+ int height;
+ int imgsize;
+
+ image = imlib_load_image(file);
+ if (image == NULL)
+ errx(1, "cannot load image %s", file);
+
+ imlib_context_set_image(image);
+
+ width = imlib_image_get_width();
+ height = imlib_image_get_height();
+ imgsize = MIN(width, height);
+
+ image = imlib_create_cropped_scaled_image(0, 0, imgsize, imgsize, size, size);
+
+ return image;
+}
+