Mounir ORFI

Yet another network engineer...

Swiggle, a Static Image Gallery Generator

| Comments

As you may notice I am using octopress/jekyll to generate the webpages of this blog, so when I tried to share few pics with my family, the natural solution that came to my mind was a static image gallery generator tool… before trying to mess around with bash and ImageMagick, I did a little search and found a nice comparison here.

I wanted something quick and minimalist that’s why I choosed Swiggle. Make sure you have libexif-dev and libexif12 before compiling it.

compile swiggle for Linux
1
2
3
4
5
mounir@mounir-laptop:~/blog/swiggle/swiggle-0.4$ make -f Makefile.Linux
gcc -Wall -I/usr/local/include -I/usr/local/include/libexif -DNO_D_TYPE   -c -o swiggle.o swiggle.c
gcc -Wall -I/usr/local/include -I/usr/local/include/libexif -DNO_D_TYPE   -c -o resize.o resize.c
gcc -Wall -I/usr/local/include -I/usr/local/include/libexif -DNO_D_TYPE   -c -o html.o html.c
gcc -Wall -I/usr/local/include -I/usr/local/include/libexif -DNO_D_TYPE -L/usr/local/lib -ljpeg -lexif -o swiggle swiggle.o resize.o html.o

Pretty straightforward

Swiggle usage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
mounir@mounir-laptop:~$ swiggle

Usage:
swiggle [options] /path/to/gallery

Available options:
   -c <x> ... columns per thumbnail index page (default: 5)
   -r <y> ... rows per thumbnail index page (default: 3)
   -h <i> ... height of the thumbnails in pixel (default: 96)
   -H <j> ... height of the scaled images in pixel (default: 480)
   -f     ... force rebuild of everything; ignore cache
   -o     ... don't remove orphaned files
   -l     ... use bilinear resizing instead of bicubic
              (faster, but image quality is poor)
   -s <n> ... sort images according to argument
              ('name', 'size', 'mtime'; default is 'name')
   -d     ... title string for gallery and albums, if not provided in
              '.description' files (default: 'my webgallery')
   -v     ... show version info

I am quite happy with the result, the only issue I had is that the encoding wasn’t properly set (seven-bit ASCII, so no accented characters):

It’s an opensource software :) below is the patch I wrote to fix this issue:

utf-8 charset patch (swiggle_utf8.diff) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
diff -up swiggle-0.4/html.c swiggle-0.4_patched/html.c
--- swiggle-0.4/html.c   2012-11-09 22:59:04.545296975 +0000
+++ swiggle-0.4_patched/html.c   2012-11-09 23:55:25.185268061 +0000
@@ -80,6 +80,7 @@ create_html(char *dir, struct imginfo *i
      
      fprintf(html, "<html>\n"
          "<head>\n"
+            "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n"
          "<title>%s: %s</title>\n"
          "<link rel=\"stylesheet\" type=\"text/css\" "
          "href=\"../swiggle.css\" />\n"
@@ -242,6 +243,7 @@ create_thumbindex(char *dir, struct imgi
      }
      
      fprintf(html, "<html>\n<head>\n<title>%s / %d</title>\n"
+            "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n"
          "<link rel=\"stylesheet\" type=\"text/css\" "
          "href=\"../swiggle.css\" />\n"
          "</head>\n<body bgcolor=\"#ffffff\">\n"
diff -up swiggle-0.4/swiggle.c swiggle-0.4_patched/swiggle.c
--- swiggle-0.4/swiggle.c    2012-11-09 22:34:09.837768732 +0000
+++ swiggle-0.4_patched/swiggle.c    2012-11-09 23:01:38.025384875 +0000
@@ -221,6 +221,7 @@ main(int argc, char **argv)
  
  fprintf(html, "<html>\n"
      "<head>\n"
+        "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n"
      "<title>%s</title>\n"
      "<link rel=\"stylesheet\" type=\"text/css\" "
      "href=\"swiggle.css\" />\n"

and voilĂ …

Comments