OSDN Git Service

use jpegtran in pc mode.
authorgn64_jp <gn64@rec10.org>
Wed, 17 Apr 2013 12:45:19 +0000 (21:45 +0900)
committergn64_jp <gn64@rec10.org>
Wed, 17 Apr 2013 12:45:19 +0000 (21:45 +0900)
jpegserver.pl

index f4e26cf..917aeaf 100755 (executable)
@@ -11,8 +11,7 @@ use DBD::SQLite;
 use Data::Dumper;
 use Image::Magick;
 use YAML::XS;
-
-#use KCatch;
+use KCatch;
 #
 #      Libre10
 #      Copyright 2013 yukikaze,long.inus
@@ -78,6 +77,12 @@ if ( $width > 0 && $height > 0 ) {
        $outputpathjpg = $outputpath_rs_jpg;
 }
 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";
@@ -98,8 +103,9 @@ else {
        print $cgi->header( -type => "text/html", -charset => "utf-8" );
        print $cgi->start_html( -title => "rec10 pdf search", -lang => "ja-JP" );
        print "error<br>";
-       print "pdftk \"$pdfpath\" cat $b - $e output \"/tmp/rec10pdf/ "
-         . basename($pdfpath) . "\"";
+       #print "pdftk \"$pdfpath\" cat $b - $e output \"/tmp/rec10pdf/ "
+       #  . basename($pdfpath) . "\"";
+       print "pdfimages -f $pagenum -l $pagenum -j '$pdfpath' $outputpath";
 }
 
 sub generate_unique_key {
@@ -153,10 +159,11 @@ sub generate_resized_image_magick {
        #$image=$image->convert(preset => 'noalpha');
        $image->Resize( width => $width, height => $height, blur => 0.8 );
        $image->Write($resized_img_path);
-       system
-"jpegtran -progressive -copy none -outfile $resized_img_path.out -optimize $resized_img_path";
-       if ( -e "$resized_img_path.out" ) {
-               system "rm $resized_img_path";
-               system "mv $resized_img_path.out $resized_img_path";
-       }
+       #system "jpegoptim --max=40 --strip-all $resized_img_path";
+       #system
+#"jpegtran -progressive -copy none -outfile $resized_img_path.out -optimize $resized_img_path";
+       #if ( -e "$resized_img_path.out" ) {
+       #       system "rm $resized_img_path";
+       #       system "mv $resized_img_path.out $resized_img_path";
+       #}
 }