2 #include <glib/gstdio.h>
5 void resize(gchar *orig, gchar *thumb)
7 gchar *argv[] = {"convert", "-resize", "200x200", orig, thumb, NULL};
9 g_spawn_sync(NULL, argv, NULL, G_SPAWN_SEARCH_PATH,
10 NULL, NULL, NULL, NULL, NULL, NULL);
13 GList *gen_thumbs(GList *images)
15 if (!g_file_test("thumbs", G_FILE_TEST_EXISTS))
16 g_mkdir("thumbs", 0644);
17 if (!g_file_test("images", G_FILE_TEST_EXISTS))
18 g_mkdir("images", 0644);
19 for (GList *cur = images; cur; cur = cur->next) {
20 gchar *name = cur->data;
21 gchar *thumb = g_strconcat("thumbs/", name, NULL);
22 gchar *image = g_strconcat("images/", name, NULL);
23 if (!g_file_test(thumb, G_FILE_TEST_EXISTS))
31 GList *read_dir(gchar *dirname)
33 GDir *dir = g_dir_open(dirname, 0, NULL);
34 const gchar *name = NULL;
36 while ((name = g_dir_read_name(dir)))
37 images = g_list_prepend(images, g_strdup(name));
46 const gchar *query_string = g_getenv("QUERY_STRING");
47 if (query_string == NULL)
49 else if (g_str_equal(query_string, "noframe"))
50 frame_nav(TRUE, gen_thumbs(read_dir("images")));
51 else if (g_str_equal(query_string, "nav"))
52 frame_nav(FALSE, gen_thumbs(read_dir("images")));
53 else if (g_str_equal(query_string, "head"))
55 else if (g_str_equal(query_string, "content"))