--- /dev/null
+#!/usr/bin/perl
+# make_djvu converts images to a djvu document
+# and is released under the terms of the GNU GPL version 3, or any
+# later version, at your option. See the file README and COPYING for
+# more information.
+# Copyright 2014 by Don Armstrong <don@donarmstrong.com>.
+
+
+use warnings;
+use strict;
+
+use Getopt::Long;
+use Pod::Usage;
+
+=head1 NAME
+
+make_djvu - converts images to a djvu document
+
+=head1 SYNOPSIS
+
+make_djvu [options] image1 [image2 ...]
+
+ Options:
+ --output, -o output file (Default out.djvu)
+ --debug, -d debugging level (Default 0)
+ --help, -h display this help
+ --man, -m display manual
+
+=head1 OPTIONS
+
+=over
+
+=item B<--output, -o>
+
+Output file (default out.djvu)
+
+=item B<--debug, -d>
+
+Debug verbosity. (Default 0)
+
+=item B<--help, -h>
+
+Display brief usage information.
+
+=item B<--man, -m>
+
+Display this manual.
+
+=back
+
+=head1 EXAMPLES
+
+make_djvu
+
+=cut
+
+
+use vars qw($DEBUG);
+
+my %options = (output => 'out.djvu',
+ debug => 0,
+ help => 0,
+ man => 0,
+ );
+
+GetOptions(\%options,
+ 'output|out|o=s',
+ 'debug|d+','help|h|?','man|m');
+
+pod2usage() if $options{help};
+pod2usage({verbose=>2}) if $options{man};
+
+$DEBUG = $options{debug};
+
+my @USAGE_ERRORS;
+if (not @ARGV) {
+ push @USAGE_ERRORS,"You must provide at least one image file";
+}
+
+pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS;
+
+my @djvu_files;
+for my $tiff (@ARGV) {
+ my $base_name = $tiff;
+ $base_name =~ s/\.[^\.]+$//;
+ system('cjb2',$base_name,$base_name.'.djvu');
+ system('tesseract',$tiff,$base_name.'.ocr');
+ my $fh = IO::File->new($base_name.'.ocr','r');
+ my $wf = IO::File->new($base_name.'.txt','w');
+ print {$wf} "(page 0 0 1 1\n";
+ if (defined $fh) {
+ my $line;
+ while ($line=<$fh>) {
+ $line =~ s/\"/\\\"/g ;
+ print {$wf} "(line 0 0 1 1 \"$line\")\n" ;
+ }
+ close $fh;
+ }
+ print {$wf} ")\n";
+ close $wf;
+ unlink($base_name.'.ocr') if -e $base_name.'.ocr';
+ system('dvjused',$base_name.'.djvu','-e','select 1; remove-txt','-s');
+ system('dvjused',$base_name.'.djvu','-e','select 1; set-txt '.$base_name.'.txt','-s');
+ unlink($base_name.'.txt') if -e $base_name.'.txt';
+ push @djvu_files,$base_name.'.djvu';
+}
+
+system('djvm','-c',$options{output},@djvu_files);
+
+
+
+
+__END__