OSDN Git Service

jpeg resize acceleration
authorgn64_jp <gn64@rec10.org>
Mon, 6 May 2013 14:06:04 +0000 (23:06 +0900)
committergn64_jp <gn64@rec10.org>
Mon, 6 May 2013 14:06:04 +0000 (23:06 +0900)
jpegserver.pl

index 9f6e00b..277a95b 100755 (executable)
@@ -2,12 +2,12 @@
 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;
 
 #
@@ -45,16 +45,10 @@ $dbi =
 $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";
@@ -84,12 +78,6 @@ if ( ( $width > 0 ) or ( $height > 0 ) ) {
        }
 }
 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";
@@ -129,13 +117,6 @@ sub generate_unique_key {
 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\"";
 }