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; } }
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); $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); // 640x480 $img_width = 640; $img_height = 640; $src_ext = ".jpg"; $out_ext = ".jpg"; $pos = stripos($path, $src_ext); $file_path = substr($path, 0, $pos); $destPath = $file_path . $out_ext; $clsResize = new clsUpload(); $clsResize->ImageResize_Ex($path, $destPath, $img_width, $img_height, $out_ext); chmod($destPath, 0755); list($width, $height) = getImageSize($destPath); $ret_str = sprintf("aaa&msg=%d+%d+%s", $width, $height, $file_name); // tossi customization // $image_info = getimagesize($destPath); // get source image width/height // $sw = $image_info[0]; $sh = $image_info[1]; // 40x30 (Thumbnail image for wap) $dw = 40; $dh = 30; $destPath = $file_path . "_w4.png"; $cmd = " -resize '{$dw}x{$dh}!' -type Palette -depth 8 {$destPath}"; // 176x240 $dw = $sw; $dh = $sh; $this->calc_resize($dw, $dh, 140, 120, true); $destPath = $file_path . "_w1.png"; $cmd = " -resize {$dw}x{$dh} -type Palette -depth 8 -write {$destPath}" . $cmd; // 240x320 $dw = $sw; $dh = $sh; $this->calc_resize($dw, $dh, 220, 180, true); $destPath = $file_path . "_w2.png"; $cmd = " -resize {$dw}x{$dh} -type Palette -depth 8 -write {$destPath}" . $cmd; // 320x240 $dw = $sw; $dh = $sh; $this->calc_resize($dw, $dh, 220, 180, true); $destPath = $file_path . "_w3.png"; $cmd = " -resize {$dw}x{$dh} -type Palette -depth 8 -write {$destPath}" . $cmd; $cmd_path = "convert"; if (file_exists("/usr/local/bin/convert")) { $cmd_path = "/usr/local/bin/convert"; } else { if (file_exists("/usr/bin/convert")) { $cmd_path = "/usr/bin/convert"; } } $cmd = "{$cmd_path} {$path} " . $cmd; $cmd_out = array(); $ret_val = 0; $ret = exec($cmd, $cmd_out, $ret_val); chmod(substr($path, 0, $pos) . "_w1.png", 0755); chmod(substr($path, 0, $pos) . "_w2.png", 0755); chmod(substr($path, 0, $pos) . "_w3.png", 0755); chmod(substr($path, 0, $pos) . "_w4.png", 0755); // test for $ret_val /* // 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; } }