2012-05-03 5 views
1

전세, 요트 및 기타 차량 예약을위한 관리자 패널을 설치했고 차량을위한 단일 이미지 만 업로드하고로드하는 데 너무 많은 시간이 걸리기 때문에 phpthumb 라이브러리를 사용하지 않고 여러 크기로 이미지 크기를 조정할 수 있습니다. 목록 페이지, 먼저 그것은 이미지의 캐시 따라서 sucks.I는 관리자가 그 차량의 여러 이미지를 업로드하지 않도록 단일 이미지의 크기를 조정하는 간단한 방법이 필요합니다.PHP 엄지 손가락을 사용하지 않고 이미지의 여러 크기를 얻는 방법?

+0

어떤 방법 으로든 이미지의 크기를 조정해야합니다. 캐싱을 사용하지 않으면 모든 페이지로드시 캐싱을 수행해야합니다. 캐싱을 사용하면 이미지가 업로드 된 후 캐시가 채워지도록 한 번만 발생하므로 최악의 경우 이미지를 업로드 한 후 모든 이미지 크기를 한 번 검색합니다. 사용자가 페이지를 볼 때가 아니라 업로드 직후에 이렇게하면 suer가 성능에 영향을주지 않아야합니다. 물론, 나는 당신이 디스크에 크기가 조정 된 이미지를 캐싱하는 것이지, 프록시와 브라우저 설정에 의존하는 간단한 웹 서버 캐싱이 아니라고 가정합니다. – Basic

답변

0

ok this은 필요한 것을하기에 매우 좋은 라이브러리입니다.

0

난 내가 만든이 기능을 사용

<?php 
function getImageXY($image, $type='original') { 
    if($type == 'original') { 
     $imgDimsMax = 200; 
    } else if($type == 'thumb') { 
     $imgDimsMax = 60; 
    } else if($type == 'defualt') { 
     $imgDimsMax = 140; 
    } 

    $aspectRatio = 1; // deafult aspect ratio...keep the image as is. 

    // set the default dimensions. 
    $imgWidth = $imgDimsMax; 
    $imgHeight = $imgDimsMax; 

    list($width, $height, $type, $attr) = getimagesize($image); 
    //$imgHeight = floor ($height * ($imgWidth/$width)); 

    if($width == $height) { 
     // if the image is less than ($imgDimsMax x $imgDimsMax), use it as is.. 
     if($width < $imgDimsMax) { 
      $imgWidth = $width; 
      $imgHeight = $height; 
     } 
    } else { 
     if($width > $height) { 
      // set $imgWidth to $imgDimsMax and resize $imgHeight proportionately 
      $aspectRatio = $imgWidth/$width; 
      $imgHeight  = floor ($height * $aspectRatio); 
     } else if($width < $height) { 
      // set $imgHeight to $imgDimsMax and resize $imgWidth proportionately 
      $aspectRatio = $imgHeight/$height; 
      $imgWidth  = floor ($width * $aspectRatio); 
     } 
    } 

    return array($imgWidth, $imgHeight); 
} 
?> 

패스 그 원래 이미지 및 치수 입력 (다른 종류의 서로 다른 크기를 지정)하고 새로운 폭과 높이를 반환한다. 호프 즉 도움이됩니다.

+1

코드에 감사하지만 확인해 봅니다. –

관련 문제