DataObjects/core.sql
[Pman.Core] / Images.php
index bc4c006..020a00a 100644 (file)
@@ -161,17 +161,26 @@ class Pman_Core_Images extends Pman
         $this->mimetype = $_REQUEST['mimetype'];
         require_once 'File/MimeType.php';
         $y = new File_MimeType();
-        $src_ext = $y->toExt($filename);
+        $src_ext = $y->toExt( $this->mimetype );
         
         
         $tmp = $this->tempName($src_ext);
         file_put_contents($tmp, $_REQUEST['data']);
         
+        require_once 'File/Convert.php';
+        $cv = new File_Convert($tmp, $this->mimetype);
         
+        $fn = $cv->convert(
+                $this->as_mimetype ,
+                empty($_REQUEST['width']) ? 0 : $_REQUEST['width'],
+                empty($_REQUEST['height']) ? 0 : $_REQUEST['height']
+        );
+        if (!empty($_REQUEST['as_data'])) {
+            $this->jok(base64_encode(file_get_contents($fn)));
+        }
         
-        
-        
-        
+        $cv->serve('attachment');
+        exit;