func.php 파일 이미지가 웹 사이트에 업로드 될 때 미리보기 이미지를 생성합니다. 나는 5 반경 둥근 모서리를 만드는 방법을 이해하지만 난 지금 내 코드에 둥근 모서리를 통합하는 경우 난처한 상황에 빠진 어떤 이유로, 도와주세요 :PHP 및 HTML을 사용하여 축소판에 둥근 모서리를 만드는 방법은 무엇입니까?
<?php
function create_thumb($directory, $image, $destination) {
$image_file = $image;
$image = $directory.$image;
if (file_exists($image)) {
$source_size = getimagesize($image);
if ($source_size !== false) {
$thumb_width = 100;
$thumb_height = 100;
switch($source_size['mime']) {
case 'image/jpeg':
$source = imagecreatefromjpeg($image);
break;
case 'image/png':
$source = imagecreatefrompng($image);
break;
case 'image/gif':
$source = imagecreatefromgif($image);
break;
}
$source_aspect = round(($source_size[0]/$source_size[1]), 1);
$thumb_aspect = round(($thumb_width/$thumb_height), 1);
if ($source_aspect < $thumb_aspect) {
$new_size = array($thumb_width, ($thumb_width/$source_size[0]) * $source_size[1]);
$source_pos = array(0, ($new_size[1] - $thumb_height)/2);
} else if ($source_aspect > $thumb_aspect) {
$new_size = array(($thumb_width/$source_size[1]) * $source_size[0], $thumb_height);
$source_pos = array(($new_size[0] - $thumb_width)/2, 0);
} else {
$new_size = array($thumb_width, $thumb_height);
$source_pos = array(0, 0);
}
if ($new_size[0] < 1) $new_size[0] = 1;
if ($new_size[1] < 1) $new_size[1] = 1;
$thumb = imagecreatetruecolor($thumb_width, $thumb_height);
imagecopyresampled($thumb, $source, 0, 0, $source_pos[0], $source_pos[1], $new_size[0], $new_size[1], $source_size[0], $source_size[1]);
switch($source_size['mime']) {
case 'image/jpeg':
imagejpeg($thumb, $destination.$image_file);
break;
case 'image/png':
imagepng($thumb, $destination.$image_file);
break;
case 'image/gif':
imagegif($thumb, $destination.$image_file);
break;
}
}
}
}
?>
을주고
CSS
을 사용할 수 있습니까? http://css3pie.com/을 사용하는 경우 IE6에서도 작동합니다. – biziclop예 CSS가 더 좋고 우아한 해결책입니다. 왜 사용하지 않니? – bksi
가능한이 질문의 중복 http://stackoverflow.com/questions/609109/rounded-corners-on-images-using-php?rq=1 – jco