コード例 #1
0
ファイル: clsBitmapSave.php プロジェクト: akswosn/tossi
 public function BitmapData2Jpg($lowdata, $path)
 {
     //$data = $GLOBALS["HTTP_RAW_POST_DATA"];
     if (is_null($lowdata)) {
         echo "No data was sent";
     } else {
         $file = fopen($path, "w") or die("Can't open file");
         if (!fwrite($file, $lowdata)) {
             echo "Error writing to file";
         }
         fclose($file);
         chmod($filename, 0777);
         $cls_config = new clsConfig();
         $url_path = trim($cls_config->GetURL($path));
         list($width, $height) = getImageSize($path);
         #$filesize = filesize($path);
         // org
         # filename
         $pos = strrpos($url_path, "/") + 1;
         $file_name = substr($url_path, $pos);
         $ret_str = sprintf("aaa&msg=%d+%d+%s", $width, $height, $file_name);
         // 140x120
         $img_width = 640;
         $img_height = 640;
         $src_ext = ".jpg";
         $out_ext = ".jpg";
         $pos = stripos($path, $src_ext);
         $destPath = substr($path, 0, $pos) . "_w0" . $out_ext;
         $clsResize = new clsUpload();
         $clsResize->ImageResize_Ex($path, $destPath, $img_width, $img_height, $out_ext);
         // 140x120
         $img_width = 140;
         $img_height = 120;
         $src_ext = ".jpg";
         $out_ext = ".png";
         $pos = stripos($path, $src_ext);
         $destPath = substr($path, 0, $pos) . "_w1" . $out_ext;
         $clsResize->ImageResize($path, $destPath, $img_width, $img_height, $out_ext);
         #$url_path = trim($cls_config->GetURL($destPath));
         # 220 x 180
         $img_width = 220;
         $img_height = 180;
         $src_ext = ".jpg";
         $out_ext = ".png";
         $pos = stripos($path, $src_ext);
         $destPath = substr($path, 0, $pos) . "_w2" . $out_ext;
         $clsResize->ImageResize($path, $destPath, $img_width, $img_height, $out_ext);
         #$url_path = trim($cls_config->GetURL($destPath));
         # 300 x 240
         $img_width = 300;
         $img_height = 240;
         $src_ext = ".jpg";
         $out_ext = ".png";
         $pos = stripos($path, $src_ext);
         $destPath = substr($path, 0, $pos) . "_w3" . $out_ext;
         $clsResize->ImageResize($path, $destPath, $img_width, $img_height, $out_ext);
         #$url_path = trim($cls_config->GetURL($destPath));
         //echo $ret_str;
         return $ret_str;
     }
 }