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); "
のようにそれを再構築したい
は私のindex.phpである
<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
<?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);
}
?>