From 97c4afdda9589c29981e535f11cc1aa65fc270e6 Mon Sep 17 00:00:00 2001 From: Stuart Longland Date: Mon, 26 Jan 2009 18:31:18 +1000 Subject: [PATCH] Photo gallery images are now automatically generated at default res and quality. --- src/main.c | 14 +++++++-- templates/generator.cs | 69 ++++++++++++++++++++++++++++++++++++++++++ templates/photo.cs | 2 +- 3 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 templates/generator.cs diff --git a/src/main.c b/src/main.c index bdcd565..62ebbf3 100644 --- a/src/main.c +++ b/src/main.c @@ -365,6 +365,9 @@ void photo_handler( struct gallery_info* gallery, /* Are we asked to show the original image? */ int original = hdf_get_int_value( cgi->hdf, "Query.original", 0 ); + + /* Are we generating the gallery? */ + int generate = hdf_get_int_value( cgi->hdf, "Query.generate", 0 ); int default_width = photo->default_dims.width; int default_height = photo->default_dims.height; @@ -404,10 +407,12 @@ void photo_handler( struct gallery_info* gallery, "at %fdeg rotation and %d quality\n", width, height, rotation, quality); - /* Request image of the specified size */ + /* Request image of the specified size + * If we're generating the gallery, we do not resize _yet_. + */ struct dimensions dims; char* resized; - if ( original ) + if ( original || generate ) resized = construct_path( "s/s", gallery->gallery_name, photo_name ); else @@ -481,7 +486,10 @@ void photo_handler( struct gallery_info* gallery, hdf_set_value( cgi->hdf, "photo.next", photo_name ); /* Render the page and display it */ - write_template( "photo.cs" ); + if ( generate ) + write_template( "generator.cs" ); + else + write_template( "photo.cs" ); } void write_template( const char* template_name ) { diff --git a/templates/generator.cs b/templates/generator.cs new file mode 100644 index 0000000..54b520e --- /dev/null +++ b/templates/generator.cs @@ -0,0 +1,69 @@ + + + Image: <?cs var:html_strip(photo.annotation) ?> (<?cs var:photo.name ?>) + + + + + + +

Thumbnail

+

+

Scaled Image

+

+ + + diff --git a/templates/photo.cs b/templates/photo.cs index ea5c50d..376db52 100644 --- a/templates/photo.cs +++ b/templates/photo.cs @@ -5,7 +5,7 @@ body { } Image: <?cs var:html_strip(photo.annotation) ?> (<?cs var:photo.name ?>) -