OSDN Git Service

prefer imagemagick -> prefer gd
authorhsur <hsur@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Wed, 6 Dec 2006 13:01:39 +0000 (13:01 +0000)
committerhsur <hsur@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Wed, 6 Dec 2006 13:01:39 +0000 (13:01 +0000)
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@518 1ca29b6e-896d-4ea0-84a5-967f57386b96

trunk/NP_TrimImage/NP_TrimImage.php
trunk/NP_TrimImage/sharedlibs/phpthumb/phpthumb.class.php
trunk/NP_TrimImage/sharedlibs/phpthumb/phpthumb.functions.php

index 0adb94a..fd3a266 100644 (file)
@@ -22,7 +22,9 @@
 
 define('NP_TRIMIMAGE_FORCE_PASSTHRU', true); //passthru(standard)
 //define('NP_TRIMIMAGE_FORCE_PASSTHRU', false); //redirect(advanced)
+
 define('NP_TRIMIMAGE_CACHE_MAXAGE', 86400 * 30); // 30days
+define('NP_TRIMIMAGE_PREFER_IMAGEMAGICK', false);
 
 require_once(dirname(__FILE__).'/sharedlibs/sharedlibs.php');
 require_once('phpthumb/phpthumb.functions.php');
@@ -45,7 +47,7 @@ class NP_TrimImage extends NucleusPlugin
        }
        
        function getVersion () {
-               return '2.1';
+               return '2.1.1';
        }
        
        function supportsFeature($what)
@@ -116,10 +118,12 @@ class NP_TrimImage extends NucleusPlugin
        {
                global $DIR_MEDIA;
                $this->fileex = array('.gif', '.jpg', '.png');
+               $cacheDir = $DIR_MEDIA.'phpthumb/';
+               $cacheDir = (is_dir($cacheDir) && @is_writable($cacheDir) ) ? $cacheDir : null;
                
                $this->phpThumbParams = array(
                        'config_document_root' => $DIR_MEDIA,
-                       'config_cache_directory' => $DIR_MEDIA.'phpthumb/',
+                       'config_cache_directory' => $cacheDir,
                        'config_cache_disable_warning' => true,
                        'config_cache_directory_depth' => 0,
                        'config_cache_maxage' => NP_TRIMIMAGE_CACHE_MAXAGE,
@@ -132,6 +136,7 @@ class NP_TrimImage extends NucleusPlugin
                        'config_max_source_pixels' => 3871488, //4Mpx
                        'config_output_format' => 'jpg',
                        'config_disable_debug' => true,
+                       'config_prefer_imagemagick' => NP_TRIMIMAGE_PREFER_IMAGEMAGICK,
                );
        }
        
@@ -348,14 +353,12 @@ class NP_TrimImage extends NucleusPlugin
                        $phpThumb->setParameter($paramKey, $paramValue);
                }
                
+               $phpThumb->setParameter('w', intval($w) );
+               $phpThumb->setParameter('h', intval($h) );
                if ($p == 'non') {
-                       $phpThumb->setParameter('w', intval($w) );
-                       $phpThumb->setParameter('h', intval($h) );
                        $phpThumb->setParameter('new', 'FFFFFF');
                } else {
                        $phpThumb->setParameter('src', '/' . $p);
-                       $phpThumb->setParameter('w', intval($w) );
-                       $phpThumb->setParameter('h', intval($h) );
                        $phpThumb->setParameter('zc', $isLefttop ? 2 : 1 );
                }
                
@@ -400,7 +403,7 @@ class NP_TrimImage extends NucleusPlugin
                // putCache
                if( !rand(0,20) ) $phpThumb->CleanUpCacheDirectory();
                $phpThumb->RenderToFile($phpThumb->cache_filename);
-               chmod($phpThumb->cache_filename, 0666);
+               @chmod($phpThumb->cache_filename, 0666);
                
                // to browser
                $phpThumb->OutputThumbnail();
index 21a029a..641f2e7 100644 (file)
@@ -1206,7 +1206,9 @@ class phpthumb {
                                        $commandline .= ' -density '.$this->dpi;
                                }
                                ob_start();
-                               $getimagesize = GetImageSize($this->sourceFilename);
+                               // added by cles
+                               //$getimagesize = GetImageSize($this->sourceFilename);
+                               $getimagesize = @GetImageSize($this->sourceFilename);
                                $GetImageSizeError = ob_get_contents();
                                ob_end_clean();
                                if (is_array($getimagesize)) {
@@ -1282,6 +1284,8 @@ class phpthumb {
 //print_r($getimagesize);
 //echo '</pre>';
 
+                                                       // added by cles
+                                                       if( $this->zc != 2 )
                                                        $commandline .= ' -gravity center';
 
                                                        if (($wAll > 0) && ($hAll > 0)) {
index 135f7bf..9b2deaa 100644 (file)
@@ -416,7 +416,9 @@ class phpthumb_functions {
                        switch ($execfunction) {
                                case 'passthru':
                                        ob_start();
-                                       $execfunction($command);
+                                       // modified by cles
+                                       //$execfunction($command);
+                                       @$execfunction($command);
                                        $returnvalue = ob_get_contents();
                                        ob_end_clean();
                                        break;
@@ -426,7 +428,9 @@ class phpthumb_functions {
                                case 'exec':
                                default:
                                        ob_start();
-                                       $returnvalue = $execfunction($command);
+                                       // modified by cles
+                                       //$returnvalue = $execfunction($command);
+                                       $returnvalue = @$execfunction($command);
                                        ob_end_clean();
                                        break;
                        }