2017-01-05 1 views
0

내 코드를 사용하여 이미지를 업로드 할 때 이미지의 크기가 조정되어 정상적으로 작동합니다. 하지만 테두리 모양을 반경으로 원의 크기를 조정하고 싶습니다.테두리 반지름으로 이미지의 크기를 조정하는 방법은 무엇입니까?

현재 200x150으로 변형됩니다.

내가 여기이

style="width:200; 
     height:200; 
     border: 1px solid rgb(221, 221, 221); 
     border-radius: 50%; 
     box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.05); " 

처럼 바꿀 싶은

<form method="post" action="" enctype="multipart/form-data" > 
 
<div style="margin-bottom: 15%; padding-left: 30%;"> 
 
\t \t 
 

 
\t \t 
 
    
 
<input type="file" name="image2" class="file" id="imgInp"/> 
 
\t <span id="topic-box"> <button type="submit" class="btn btn-primary" name="savepic" >upload</button></span> 
 
</div> 
 
<?php 
 
    if(isset($_POST['savepic'])){ 
 
     $post_image2 = $_FILES['image2']['name']; 
 
     $image_tmp2 = $_FILES['image2']['tmp_name']; 
 
     $kaboom = explode(".", $post_image2); // Split file name into an array using the dot 
 
     $fileExt = end($kaboom); // Now target the last array element to get the file extension 
 
     move_uploaded_file($image_tmp2,"uploads/$post_image2"); 
 

 
\t \t \t // ---------- Include Universal Image Resizing Function -------- 
 
include_once("reshape.php"); 
 
$target_file = "uploads/$post_image2"; 
 
$resized_file = "uploads/resized_$post_image2"; 
 
$wmax = 200; 
 
$hmax = 150; 
 
ak_img_resize($target_file, $resized_file, $wmax, $hmax, $fileExt); 
 
// ----------- End Universal Image Resizing Function ----------- 
 
\t \t \t } 
 
    ?> 
 
</form>
여기

이 reshape.php 내 index.php를하다

<?php 
 
// Function for resizing jpg, gif, or png image files 
 
function ak_img_resize($target, $newcopy, $w, $h, $ext) { 
 
    list($w_orig, $h_orig) = getimagesize($target); 
 
    $scale_ratio = $w_orig/$h_orig; 
 
    if (($w/$h) > $scale_ratio) { 
 
      $w = $h * $scale_ratio; 
 
    } else { 
 
      $h = $w/$scale_ratio; 
 
    } 
 
    $img = ""; 
 
    $ext = strtolower($ext); 
 
    if ($ext == "gif"){ 
 
     $img = imagecreatefromgif($target); 
 
    } else if($ext =="png"){ 
 
     $img = imagecreatefrompng($target); 
 
    } else { 
 
     $img = imagecreatefromjpeg($target); 
 
    } 
 
    $tci = imagecreatetruecolor($w, $h); 
 
    // imagecopyresampled(dst_img, src_img, dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h) 
 
    imagecopyresampled($tci, $img, 0, 0, 0, 0, $w, $h, $w_orig, $h_orig); 
 
    imagejpeg($tci, $newcopy, 80); 
 
} 
 
?>
,

답변

0

당신은 당신이 20 %로, 이미지의 50 % 국경 반경을 축소하는 고려해야 할, 나는 reshape.php에 코드 줄을 시도 할 것

imagejpeg($tci, $newcopy, 50); 
관련 문제