2012-08-14 7 views
1

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; 
    } 


} 

    } 
} 
?> 
+0

을주고 CSS을 사용할 수 있습니까? http://css3pie.com/을 사용하는 경우 IE6에서도 작동합니다. – biziclop

+0

예 CSS가 더 좋고 우아한 해결책입니다. 왜 사용하지 않니? – bksi

+0

가능한이 질문의 중복 http://stackoverflow.com/questions/609109/rounded-corners-on-images-using-php?rq=1 – jco

답변

2

이 코드는 이미지의 일부처럼 보인다 만드는 과정
이미지의 스타일을 지정하려면 해당 파일의 출력을 처리해야합니다.

클라이언트 측에 HTML을 생성하는 코드가 있습니까? 그렇다면
는 각 img에게 수업을 포기하고 그냥 CSS의`국경 radius`를 사용할 수 없습니다 그것을 모서리

.ui-corner-all { -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; } 
+0

예 지금은 그것을보고 있습니다. 나는 어떤 이유로 그것을 생각하는 길이었습니다. 그렇기 때문에 실용적이지 않기 때문에 그 파일에 그 파일을 통합하는 방법을 알 수 없었습니다. 고맙습니다. –

관련 문제