pkg_freqs
generate_ps generate_pdf do_print
csv_from_fixed
+ ocr_image
);
$DEBUG = 0;
# join("\n", map { " $_: ". $options{$_} } keys %options ). "\n"
}
- my $to = ref($options{to}) ? join(', ', @{ $options{to} } ) : $options{to};
+ my @to = ref($options{to}) ? @{ $options{to} } : ( $options{to} );
my @mimeargs = ();
my @mimeparts = ();
my $message = MIME::Entity->build(
'From' => $options{'from'},
- 'To' => $to,
+ 'To' => join(', ', @to),
'Sender' => $options{'from'},
'Reply-To' => $options{'from'},
'Date' => time2str("%a, %d %b %Y %X %z", time),
$transport = Email::Sender::Transport::SMTP->new( %smtp_opt );
}
+ push @to, $options{bcc} if defined($options{bcc});
local $@; # just in case
- eval { sendmail($message, { transport => $transport }) };
+ eval { sendmail($message, { transport => $transport,
+ from => $options{from},
+ to => \@to }) };
if(ref($@) and $@->isa('Email::Sender::Failure')) {
return ($@->code ? $@->code.' ' : '').$@->message
Recipient address, required
+=item bcc
+
+Blind copy address, optional
+
=item subject
email subject, required
my %return = (
'from' => $args{'from'},
'to' => $args{'to'},
+ 'bcc' => $args{'bcc'},
'subject' => $args{'subject'},
);
'';
}
+=item ocr_image IMAGE_SCALAR
+
+Runs OCR on the provided image data and returns a list of text lines.
+
+=cut
+
+sub ocr_image {
+ my $logo_data = shift;
+
+ #XXX use conf dir location from Makefile
+ my $dir = $FS::UID::conf_dir. "/cache.". $FS::UID::datasrc;
+ my $fh = new File::Temp(
+ TEMPLATE => 'bizcard.XXXXXXXX',
+ SUFFIX => '.png', #XXX assuming, but should handle jpg, gif, etc. too
+ DIR => $dir,
+ UNLINK => 0,
+ ) or die "can't open temp file: $!\n";
+
+ my $filename = $fh->filename;
+
+ print $fh $logo_data;
+ close $fh;
+
+ run( [qw(ocroscript recognize), $filename], '>'=>"$filename.hocr" )
+ or die "ocroscript recognize failed\n";
+
+ run( [qw(ocroscript hocr-to-text), "$filename.hocr"], '>pipe'=>\*OUT )
+ or die "ocroscript hocr-to-text failed\n";
+
+ my @lines = split(/\n/, <OUT> );
+
+ foreach (@lines) { s/\.c0m\s*$/.com/; }
+
+ @lines;
+}
=back