[Bins] Add images from gqview

Dragos Constantinescu d.constantinescu at tu-bs.de
Thu Nov 10 16:16:49 GMT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi

I've attached a small perl script with makes easy to add pictures 
to an album from gqview.

Suppose you have your pictures organized into a directory tree and you 
want to add only some of them to your web album. This script will 
replicate your directory structure to the desired location and link the 
selected file there with a key press. It will also transfer the 
gqview comment (but only if you store the metadata local to the source 
images) to the xml description field of the image.

Maybe somebody finds it useful

________________________

         Dragos                                PGP key ID: A0887098

2005-11-10
5:03pm


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: For info see http://quantumlab.net/pine_privacy_guard/

iD8DBQFDc3J4unb5IaCIcJgRAqP/AJ93nLJeMLhQNYPj67ng0XeJnygbjgCcChly
eHp3q0QYvbEc3i4QZM4Z7kc=
=K4pJ
-----END PGP SIGNATURE-----
-------------- next part --------------
#!/usr/bin/perl -w

# written by Dragos Constantinescu <dragos at venus.nipne.ro> 2005

# This script is useful if you have lots of pictures into a directory structure
# and you want to add only some of them to a web album preserving the initial
# structure.

# To be used in conjunction to gqview and bins
# Change $imgdir and $targetdir_base according to your preferences
# Add this script to Edit->Preferences->Editors in gqview 
# It links the argument (image under $imgdir) into a mirror directory structure
# under $targetdir_base
# Also sets the bins description field of the linked image 
# to the gqview comment of the original image
# Example: the image
# /space/dragos/poze/canon/2004/braunschweig/someimage.jpg
# will be linked to
# /space/dragos/www/src-pcs/canon/2004/braunschweig/someimage.jpg
# and the gqview comment will be transfered to the description field in file 
# /space/dragos/www/src-pcs/canon/2004/braunschweig/someimage.jpg.xml
# After you add all your images to the album source you can create the album 
# with bins $targetdir_base final_album_directory

$file = $ARGV[0];

$imgdir='/space/dragos/poze/';
$targetdir_base='/space/dragos/www/src-pcs/';
$file =~/$imgdir(.+\/)(.+?)$/;
$targetdir=$targetdir_base.$1;
$link_name=$targetdir.$2;

%meta=read_meta($file); @kw=@{$meta{'keywords'}}; $comment=$meta{'comment'};

print "$file:
       keywords: @kw
       comment:  $comment\n";

system "mkdirhier $targetdir
        chmod a+rx $targetdir
        ln $file $link_name
        /usr/local/bin/bins_edit --description \"$comment\" $link_name\n";


sub read_meta {
  my $img=$_[0];
  $img=~/^(.+\/)(.+?)$/;
  my ($path,$imgname)=($1,$2);
  my $metafile=$path.".metadata/".$imgname.".meta";
  my @keywords=(); my $comment="";
  my %meta=(keywords => \@keywords, comment => $comment);
  return %meta unless -r $metafile;

  my $field='';
  open(MFILE,"<$metafile");
  while (<MFILE>){
    chomp(my $line=$_);
    if ($line=~/^\[(.+)\]$/){
      $field=$1;
      next;
    }
    next if $field eq '';
    last if $line =~/#end/;
    if ($field eq "keywords") {
      push @keywords,$line; 
    } elsif ($field eq "comment") {
      $meta{'comment'}.="$line ";
    }
  }
  
  close MFILE;
  return %meta;
}




More information about the Bins mailing list