#!/usr/bin/perl -w # Copyright © 2003, 2004, 2005 Jamie Zawinski # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation. No representations are made about the suitability of this # software for any purpose. It is provided "as is" without express or # implied warranty. # # For each file on the command line, runs "gimp-remote" to load that # image into GIMP; then waits for you to hit return before loading the # next one. Also makes sure that GIMP is running first. # # Created: 22-Jun-2003. require 5; use diagnostics; use strict; my $progname = $0; $progname =~ s@.*/@@g; my $version = q{ $Revision: 1.3 $ }; $version =~ s/^[^0-9]+([0-9.]+).*$/$1/; my $verbose = 0; sub ensure_gimp_running { my $pid = `pidof gimp`; chop($pid); if ($pid eq '') { print STDOUT "launching gimp...\n"; my $cmd = "( gimp >/dev/null 2>&1 & )"; print STDERR "$progname: exec: $cmd\n" if ($verbose); system $cmd; sleep (10); } } sub gimp_it { my ($file, $n, $m) = @_; ensure_gimp_running(); my $cmd = "gimp-remote $file >/dev/null 2>&1"; print STDERR "$progname: exec: $cmd\n" if ($verbose); print STDOUT "$file ($n / $m) ... "; system $cmd; if ($n == $m) { print STDOUT "\n"; } else { my $junk = ; } check_exif ($file); } sub check_exif { my ($file) = @_; my $cmd = "exiftool -model $file"; if (`$cmd` =~ m/^\s*$/s) { print STDERR "$progname: $file: WARNING: no EXIF data\n"; } } sub error { my ($err) = @_; print STDERR "$progname: $err\n"; exit 1; } sub usage { print STDERR "usage: $progname [--verbose] files...\n"; exit 1; } sub main { my @files = (); while ($#ARGV >= 0) { $_ = shift @ARGV; if ($_ eq "--verbose") { $verbose++; } elsif (m/^-v+$/) { $verbose += length($_)-1; } elsif (m/^-./) { usage; } else { push @files, $_; } } usage() if ($#files < 0); my $i = 1; foreach (@files) { gimp_it ($_, $i++, $#files+1); } } main; exit 0;