diff options
author | Zeus Panchenko <zeus@camb.us> | 2008-06-26 12:10:04 +0000 |
---|---|---|
committer | Zeus Panchenko <zeus@camb.us> | 2008-06-26 12:10:04 +0000 |
commit | 0b9d0cb9de24c96672c785f22a27e2bbbcae0c55 (patch) | |
tree | f20838f46ce37f2367414a0ae81ca739ea81a668 | |
parent | 3c9f1c1857906b9b7a059cb2cfa071ee9d3d097d (diff) | |
download | renrot-0b9d0cb9de24c96672c785f22a27e2bbbcae0c55.tar.gz renrot-0b9d0cb9de24c96672c785f22a27e2bbbcae0c55.tar.bz2 |
thm_gen_orig() edited, now can return a value
git-svn-id: file:///svnroot/renrot/trunk@537 fe2816f4-e837-0410-b10a-f608c9d244a1
-rwxr-xr-x | renrot | 92 |
1 files changed, 50 insertions, 42 deletions
@@ -1524,24 +1524,65 @@ sub contactSheetGenerator { # See Also : contactSheetGenerator(); sub thm_gen_stub { my $workdir = shift; - my $thmbname = shift; - $thmbname = $workdir . $thmbname; + my $file = shift; + my $thm_name = $workdir . $file; my $size = $cfgOpts{'generate thumbnail size'}; my $thmb = Image::Magick->new; - $thmb->Set(size => $size, filename => $thmbname, quality => 95, interlace => 'Partition'); + $thmb->Set(size => $size, filename => $thm_name, quality => 95, interlace => 'Partition'); $thmb->ReadImage("gradient:" . colorValidator($cfgOpts{'contact sheet thm grad fr'}) . "-" . colorValidator($cfgOpts{'contact sheet thm grad to'})); $thmb->Annotate ( - pointsize => 25, - fill => colorValidator($cfgOpts{'contact sheet thm fill'}), - font => $cfgOpts{'contact sheet thm font'}, - text => $cfgOpts{'contact sheet thm text'}, - gravity => 'Center', - ); + pointsize => 25, + fill => colorValidator($cfgOpts{'contact sheet thm fill'}), + font => $cfgOpts{'contact sheet thm font'}, + text => $cfgOpts{'contact sheet thm text'}, + gravity => 'Center', + ); + + my $thmbnum = $thmb->Write(); + + if ($thmbnum) { errmsg ("$thmbnum\n\n"); } + undef $thmb; + + procmsg ("Stub thumbnail image've been created.\n"); +} + +######################################################################################## +# Usage : thm_gen_orig($thmbname); +# Purpose : generate thumbnail image from the original file and write it +# : to the ThumbnailImage tag +# Returns : thumbnail file name if unlink not asked +# Parameters : $file str - original image name +# : $unlink bin - 0 not to kill generated thumbnail +# : 1 to kill generated thumbnail +# Throws : no exceptions +# Comments : none +# See Also : n/a +sub thm_gen_orig { + my $file = shift; + my $unlink = shift; + my $thm_name = "thm_" . $file; + my $size = $cfgOpts{'generate thumbnail size'}; + my $thmb = Image::Magick->new; + + $thmb->Set(size => $size, filename => $thm_name, quality => 95, interlace => 'Partition'); + + $thmb->ReadImage($file); + $thmb->Thumbnail(geometry => $size); + my $thmbnum = $thmb->Write(); if ($thmbnum) { errmsg ("$thmbnum\n\n"); } undef $thmb; + + if ( $unlink ) { + ldbg3("attempt to write ThumbnailImage tag to $file\n"); + thumbWriter($file, getFileData($thm_name)); + unlink $thm_name; + } else { + ldbg3("ThumbnailImage was generated for $file\n"); + return $thm_name; + } } ######################################################################################## @@ -1856,39 +1897,6 @@ sub rotateThumbnail { } ######################################################################################## -# Usage : thm_gen_orig($thmbname); -# Purpose : generate thumbnail image from the original file and write it -# : to the ThumbnailImage tag -# Returns : none -# Parameters : $file str - original image name -# Throws : no exceptions -# Comments : none -# See Also : n/a -sub thm_gen_orig { - my $file = shift; - my $thm_name = "thm_" . $file; - my $size = $cfgOpts{'generate thumbnail size'}; - my $thmb = Image::Magick->new; - - $thmb->Set(size => $size, filename => $thm_name, quality => 95, interlace => 'Partition'); - - $thmb->ReadImage($file); - $thmb->Thumbnail(geometry => $size); - - my $thmbnum = $thmb->Write(); - - if ($thmbnum) { errmsg ("$thmbnum\n\n"); } - undef $thmb; - - thumbWriter($file, getFileData($thm_name)); - - unlink $thm_name; - - ldbg3("ThumbnailImage tag generated for the file $file\n"); -} - - -######################################################################################## # Usage : piper(); # Purpose : opens two pipes for process object via the command passed as argument # Returns : $pipe_obj processed via $pipe_cmd |