Changeset 18609 for tmp/version-2_5-test/data/class/SC_Image.php
- Timestamp:
- 2010/03/11 10:35:11 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tmp/version-2_5-test/data/class/SC_Image.php
r18562 r18609 29 29 function SC_Image($tmp_dir) { 30 30 // ヘッダファイル読込 31 if (!ereg("/$", $tmp_dir)) {31 if (!ereg("/$", $tmp_dir)) { 32 32 $this->tmp_dir = $tmp_dir . "/"; 33 33 } else { … … 52 52 $from_path = $this->tmp_dir.$filename; 53 53 $to_path = $save_dir."/".$filename; 54 if (file_exists($from_path) && file_exists($save_dir)) {55 if (copy($from_path , $to_path)) {54 if (file_exists($from_path) && file_exists($save_dir)) { 55 if (copy($from_path , $to_path)) { 56 56 unlink($from_path); 57 57 } … … 63 63 //---- 指定ファイルを削除 64 64 function deleteImage($filename, $dir) { 65 if (file_exists($dir."/".$filename)) {65 if (file_exists($dir."/".$filename)) { 66 66 unlink($dir."/".$filename); 67 67 } … … 88 88 $PreWord = $head; 89 89 90 91 92 93 94 90 //拡張子取得 91 if (!$ext) { 92 $array_ext = explode(".", $FromImgPath); 93 $ext = $array_ext[count($array_ext) - 1]; 94 } 95 95 96 96 $MW = $ThmMaxWidth; 97 if ($tmpMW) $MW = $tmpMW; // $MWに最大横幅セット97 if ($tmpMW) $MW = $tmpMW; // $MWに最大横幅セット 98 98 99 99 $MH = $ThmMaxHeight; 100 if ($tmpMH) $MH = $tmpMH; // $MHに最大縦幅セット101 102 if (empty($FromImgPath) || empty($ToImgPath)){100 if ($tmpMH) $MH = $tmpMH; // $MHに最大縦幅セット 101 102 if (empty($FromImgPath) || empty($ToImgPath)){ 103 103 return array(0,"出力元画像パス、または出力先フォルダが指定されていません。"); 104 104 } 105 105 106 if (!file_exists($FromImgPath)){106 if (!file_exists($FromImgPath)){ 107 107 return array(0,"出力元画像が見つかりません。"); 108 108 } … … 111 111 $re_size = $size; 112 112 113 if (!$size[2] || $size[2] > 3){ // 画像の種類が不明 or swf113 if (!$size[2] || $size[2] > 3){ // 画像の種類が不明 or swf 114 114 return array(0,"画像形式がサポートされていません。"); 115 115 } … … 118 118 $tmp_w = $size[0] / $MW; 119 119 120 if ($MH != 0){120 if ($MH != 0){ 121 121 $tmp_h = $size[1] / $MH; 122 122 } 123 123 124 if ($tmp_w > 1 || $tmp_h > 1){125 if ($MH == 0){126 if ($tmp_w > 1){124 if ($tmp_w > 1 || $tmp_h > 1){ 125 if ($MH == 0){ 126 if ($tmp_w > 1){ 127 127 $re_size[0] = $MW; 128 128 $re_size[1] = $size[1] * $MW / $size[0]; 129 129 } 130 130 } else { 131 if ($tmp_w > $tmp_h){131 if ($tmp_w > $tmp_h){ 132 132 $re_size[0] = $MW; 133 133 $re_size[1] = $size[1] * $MW / $size[0]; … … 148 148 switch($size[2]) { 149 149 case "1": //gif形式 150 if ($tmp_w <= 1 && $tmp_h <= 1){151 if ( $newFileName) {150 if ($tmp_w <= 1 && $tmp_h <= 1){ 151 if ($newFileName) { 152 152 $ToFile = $newFileName; 153 153 } elseif ($ext) { … … 156 156 $ToFile .= ".gif"; 157 157 } 158 if (!@copy($FromImgPath , $ToImgPath.$ToFile)) { // エラー処理158 if (!@copy($FromImgPath , $ToImgPath.$ToFile)) { // エラー処理 159 159 return array(0,"ファイルのコピーに失敗しました。"); 160 160 } … … 169 169 ImageRectangle ($ImgNew,0,0,($re_size[0]-1),($re_size[1]-1), $black); 170 170 171 if ( $newFileName) {171 if ($newFileName) { 172 172 $ToFile = $newFileName; 173 } elseif ($ext) {173 } elseif ($ext) { 174 174 $ToFile .= "." . $ext; 175 175 } else { … … 178 178 $TmpPath = $ToImgPath.$ToFile; 179 179 @Imagepng($ImgNew,$TmpPath); 180 if (!@file_exists($TmpPath)){ // 画像が作成されていない場合180 if (!@file_exists($TmpPath)){ // 画像が作成されていない場合 181 181 return array(0,"画像の出力に失敗しました。"); 182 182 } … … 188 188 //ImageCopyResized( $ImgNew,$ImgDefault, 0, 0, 0, 0,$re_size[0], $re_size[1],$size[0], $size[1]); 189 189 190 if ($re_size[0] != $size[0] || $re_size[0] != $size[0]) {190 if ($re_size[0] != $size[0] || $re_size[0] != $size[0]) { 191 191 ImageCopyResampled( $ImgNew,$ImgDefault, 0, 0, 0, 0,$re_size[0], $re_size[1],$size[0], $size[1]); 192 192 } … … 197 197 198 198 199 if ( $newFileName) {199 if ($newFileName) { 200 200 $ToFile = $newFileName; 201 } elseif ($ext) {201 } elseif ($ext) { 202 202 $ToFile .= "." . $ext; 203 203 } else { … … 206 206 $TmpPath = $ToImgPath.$ToFile; 207 207 @ImageJpeg($ImgNew,$TmpPath); 208 if (!@file_exists($TmpPath)){ // 画像が作成されていない場合208 if (!@file_exists($TmpPath)){ // 画像が作成されていない場合 209 209 return array(0,"画像の出力に失敗しました。<br>${ImgNew}<br>${TmpPath}"); 210 210 } … … 217 217 ImageCopyResampled($ImgNew, $ImgDefault, 0, 0, 0, 0,$re_size[0], $re_size[1],$size[0], $size[1]); 218 218 219 if ( $newFileName) {219 if ($newFileName) { 220 220 $ToFile = $newFileName; 221 221 } elseif ($ext) { … … 226 226 $TmpPath = $ToImgPath.$ToFile; 227 227 @ImagePNG($ImgNew,$TmpPath ); 228 if (!@file_exists($TmpPath)){ // 画像が作成されていない場合228 if (!@file_exists($TmpPath)){ // 画像が作成されていない場合 229 229 return array(0,"画像の出力に失敗しました。"); 230 230 }
Note: See TracChangeset
for help on using the changeset viewer.