use utf8;
use Encode 'decode';
use File::Basename;
-use warnings;
+#use warnings;
use CGI;
-use CGI::Carp qw(fatalsToBrowser);
+#use CGI::Carp qw(fatalsToBrowser);
use DBI;
use DBD::SQLite;
-use Data::Dumper;
+#use Data::Dumper;
use YAML::XS;
#
$dbi_state = $dbi->prepare("SELECT path FROM pdffile WHERE id='$pdfpath'");
$dbi_state->execute();
-#print $cgi->header;
-#print $cgi->start_html;
-#print Dumper $dbi;
$pdfpath = $dbi_state->fetchrow_array;
$dbi->disconnect;
-#print $pdfpath;
if ( -e "/tmp/libre10" ) {
-
- #"";
}
else {
system "mkdir /tmp/libre10";
}
}
if ( -e $outputpathjpg ) {
- system
-"jpegtran -progressive -copy none -outfile $outputpathjpg.out -optimize $outputpathjpg";
- if ( -e "$outputpathjpg.out" ) {
- system "rm $outputpathjpg";
- system "mv $outputpathjpg.out $outputpathjpg";
- }
$size = -s $outputpathjpg;
print "Content-type: image/jpeg\n";
print "Content-length:", $size, "\n";
sub generate_resized_image {
my ( $img_path, $resized_img_path, $width, $height ) = @_;
$size = "$width" . "x" . "$height";
-
-#print $cgi->header( -type => "text/html", -charset => "utf-8" );
-#print $cgi->start_html( -title => "rec10 pdf search", -lang => "ja-JP" );
-#print "error<br>";
-#print "convert -define jpeg:size=$size -scale $size \"$img_path\" \"$resized_img_path\"";
-# system
-#"convert -define jpeg:size=$size -fuzz 50% -trim -quality 60 -border 2%x2% -bordercolor '#ffffff' -scale $size \"$img_path\" \"$resized_img_path\"";
system
-"convert -define jpeg:size=$size -quality 60 -scale $size \"$img_path\" \"$resized_img_path\"";
+"convert -define jpeg:size=$size -quality 60 -thumbnail $size\\> \"$img_path\" \"$resized_img_path\"";
}