function createThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbWidth, $quality){ - $details = getimagesize("$imageDirectory/$imageName") or die('画像のみをアップロードしてください.');
- $type = preg_replace('@^.+(?<=/)(.+)$@', '$1', $details['mime']);
- eval('$srcImg = imagecreatefrom'.$type.'("$imageDirectory/$imageName");');
- $thumbHeight = $details[1] * ($thumbWidth / $details[0]);
- $thumbImg = imagecreatetruecolor($thumbWidth, $thumbHeight);
- imagecopyresampled($thumbImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight,
- $details[0], $details[1]);
- eval('image'.$type.'($thumbImg, "$thumbDirectory/$imageName"'.
- (($type=='jpeg')?', $quality':'').');' );
- imagedestroy($srcImg);
- imagedestroy($thumbImg);
- }
- foreach ($_FILES["pictures"]["error"] as $key => $error) {
- if ($error == UPLOAD_ERR_OK) {
- $tmp_name = $_FILES["pictures"][ "tmp_name"][$key];
- $name = $_FILES["写真"]["名前"][$key];
- move_uploaded_file($tmp_name, "データ/$name");
- createThumbnail("/メイン/画像の/場所/", $name, "/場所/ストア/サム", 120, 80);
- //120 = 親指の幅 :: 80 = 親指の品質 (1-100)
- }
- }
- ?>
-
复制代
|