don't background thumbnail creation when we'll be using "identify" to know the exact...
authorgc <gc>
Sat, 2 Apr 2005 12:04:58 +0000 (12:04 +0000)
committergc <gc>
Sat, 2 Apr 2005 12:04:58 +0000 (12:04 +0000)
bin/booh
lib/booh/booh-lib.rb

index 2bc65c8220493490a3cd80f316b42c8d5db3aef6..dc6781391f2c41d60123629937894653989bd891 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -381,8 +381,8 @@ def walk_source_dir
                 thumbnail_dest_img  = base_dest_img + "-#{size_thumbnails}.jpg"
                 fullscreen_images[sizeobj['name']] << File.basename(fullscreen_dest_img)
                 thumbnail_images[sizeobj['name']]  << File.basename(thumbnail_dest_img)
-                gen_thumbnails("#{dir}/#{img}", xmldir, [ { 'filename' => fullscreen_dest_img, 'size' => size_fullscreen },
-                                                          { 'filename' => thumbnail_dest_img, 'size' => size_thumbnails } ])
+                gen_thumbnails("#{dir}/#{img}", xmldir, true, [ { 'filename' => fullscreen_dest_img, 'size' => size_fullscreen },
+                                                                { 'filename' => thumbnail_dest_img, 'size' => size_thumbnails } ])
             end
         }
 
@@ -395,7 +395,7 @@ def walk_source_dir
                 size_thumbnails = sizeobj['thumbnails']
                 thumbnail_dest_img = dest_dir + '/' + make_dest_filename(video.sub(/\.[^\.]+$/, '')) + "-#{size_thumbnails}.jpg"
                 thumbnail_videos[sizeobj['name']] << File.basename(thumbnail_dest_img)
-                thumbnail_ok &&= gen_thumbnails("#{dir}/#{video}", xmldir, [ { 'filename' => thumbnail_dest_img, 'size' => size_thumbnails } ])
+                thumbnail_ok &&= gen_thumbnails("#{dir}/#{video}", xmldir, true, [ { 'filename' => thumbnail_dest_img, 'size' => size_thumbnails } ])
             end
             destvideo = "#{dest_dir}/#{video}"
             if !File.exists?(destvideo)
@@ -594,7 +594,7 @@ def walk_source_dir
             #- deal with "current" album (directs to "thumbnails" page)
             if xmldir.attributes['thumbnails-caption']
                 thumbnail = "#{dest_dir}/thumbnails-thumbnail.jpg"
-                gen_thumbnails(from_utf8(xmldir.attributes['thumbnails-captionfile']), xmldir, [ { 'filename' => thumbnail, 'size' => $albums_thumbnail_size } ])
+                gen_thumbnails(from_utf8(xmldir.attributes['thumbnails-captionfile']), xmldir, false, [ { 'filename' => thumbnail, 'size' => $albums_thumbnail_size } ])
                 html_index += run_iterations(iterations)
                 html_index.gsub!(/~~image_iteration~~/, "<a href='thumbnails-#{default_thumbnails}.html'>" + img_element(thumbnail) + '</a>')
                 html_index.gsub!(/~~caption_iteration~~/, xmldir.attributes['thumbnails-caption'])
@@ -610,10 +610,10 @@ def walk_source_dir
                 #- first look for subdirs info; if not, means there is no subdir
                 caption = child.attributes['subdirs-caption']
                 if caption
-                    gen_thumbnails(from_utf8(child.attributes['subdirs-captionfile']), child, [ { 'filename' => thumbnail, 'size' => $albums_thumbnail_size } ])
+                    gen_thumbnails(from_utf8(child.attributes['subdirs-captionfile']), child, false, [ { 'filename' => thumbnail, 'size' => $albums_thumbnail_size } ])
                     html_index.gsub!(/~~caption_iteration~~/, caption)
                 else
-                    gen_thumbnails(from_utf8(child.attributes['thumbnails-captionfile']), child, [ { 'filename' => thumbnail, 'size' => $albums_thumbnail_size } ])
+                    gen_thumbnails(from_utf8(child.attributes['thumbnails-captionfile']), child, false, [ { 'filename' => thumbnail, 'size' => $albums_thumbnail_size } ])
                     html_index.gsub!(/~~caption_iteration~~/, child.attributes['thumbnails-caption'])
                 end
                 html_index.gsub!(/~~image_iteration~~/, "<a href='#{make_dest_filename(subdir)}/index.html'>" + img_element(thumbnail) + '</a>')
index 6edf2afe541f7875e2a4b16331b1181c8fb004c4..942d5fb0bc7ff08b20594b4ad6060c97e78274ff 100644 (file)
@@ -137,7 +137,7 @@ module Booh
         end
     end
 
-    def gen_thumbnails(orig, xmldir, dests)
+    def gen_thumbnails(orig, xmldir, allow_background, dests)
         if !dests.detect { |dest| !File.exists?(dest['filename']) } 
             return true
         end
@@ -163,7 +163,12 @@ module Booh
             end
             for dest in dests
                 if !File.exists?(dest['filename'])
-                    psys("#{$convert} #{convert_options}-geometry #{dest['size']} '#{orig}' '#{dest['filename']}'")
+                    cmd = "#{$convert} #{convert_options}-geometry #{dest['size']} '#{orig}' '#{dest['filename']}'"
+                    if allow_background
+                        psys(cmd)
+                    else
+                        sys(cmd)
+                    end
                 end
             end
             return true