fix image issue
authorAlan <alan@roojs.com>
Tue, 26 Mar 2024 04:45:14 +0000 (12:45 +0800)
committerAlan <alan@roojs.com>
Tue, 26 Mar 2024 04:45:14 +0000 (12:45 +0800)
File/Convert.php
File/Convert/Solution.php
File/Convert/Solution/scaleimage.php

index 6cf3a85..22c4fe5 100644 (file)
@@ -104,7 +104,7 @@ class File_Convert
         
         //echo "testing scale image";
         require_once 'File/Convert/Solution/scaleimage.php';
-        $sc = new File_Convert_Solution_scaleimage($toMimetype, $toMimetype);
+        $sc = new File_Convert_Solution_scaleimage($toMimetype, $toMimetype, self::$options);
         //$sc->convert = $this;
         $sc->debug= $this->debug;
         $this->solutions[] = $sc;
@@ -187,7 +187,7 @@ class File_Convert
             require_once 'File/Convert/Solution/'. $scf . '.php';
             $scls = 'File_Convert_Solution_' . $scf;
                 
-            $sc = new $scls($toMimetype, $toMimetype);
+            $sc = new $scls($toMimetype, $toMimetype, self::$options);
             $sc->debug=  $this->debug;
             $this->solutions[] = $sc;
             $x  = str_replace('c', 'x', $x);
index 586174b..85b33b0 100644 (file)
@@ -2,6 +2,7 @@
 
 class File_Convert_Solution
 {
+    static $options = array();
     var $type = 0;
     var $from;  // mimetype
     var $to; // mimetype
@@ -15,7 +16,7 @@ class File_Convert_Solution
     
     var $cmd;
     
-    function __construct(  $from ,$to)
+    function __construct(  $from ,$to, $options=array())
     {
          
         $this->from = $from;
@@ -24,6 +25,8 @@ class File_Convert_Solution
         require_once 'File/MimeType.php';
         $mt = new File_MimeType();
         $this->ext = $mt->toExt($this->to);
+
+        self::$options = $options;
          
         //$this->last = $this; //?? used where?
         
index da4b8b1..722cadb 100644 (file)
@@ -92,7 +92,14 @@ class File_Convert_Solution_scaleimage extends File_Convert_Solution
                     $scale = '';
                     $define  = '';
                 }
-                $extent ="-extent '{$x}x{$y}>' -gravity center -background white {$define}";
+                
+                $extent ="-extent '{$x}x{$y}>' -gravity center " . 
+                    (
+                        (!empty(self::$options['transparent_background'])) ? 
+                        "-transparent white" :
+                        "-background white"
+                    ) . 
+                    " {$define}";
                 break;
         }