메뉴 건너뛰기

프로그램언어

조회 수 1643 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
함수를 호출할 때 $file_src로 지정되어있는 이미지 파일 경로를 넣어주시면 됩니다.

$newsize=imgresize("파일경로");

이렇게 사용하시면 newsize[0] 에 가로길이가, newsize[1]에 세로길이가 반환되겠죠?
====================================================================
<?
function imgresize($file_src) {
$size = getimagesize("$file_src");
$width = $size[0];
$height = $size[1];
$limit_h = 422;
$limit_w = 563;
$percentage_h = $height/$limit_h;
$percentage_w = $width/$limit_w;

if($height > $limit_h || $width > $limit_w) {

if(($height > $limit_h && $width > $limit_w && $percentage_w > $percentage_h) || ($height < $limit_h && $width > $limit_w))
{$percentage = $percentage_w;}

elseif(($height >= $limit_h && $width >= $limit_w && $percentage_w < $percentage_h) || ($height >= $limit_h && $width < $limit_w))
{$percentage = $percentage_h;}

} else {$percentage = 1;}

$resize_h = $height/$percentage;
$resize_w = $width/$percentage;
$newsize = array("$resize_w", "$resize_h");
return $newsize;
}
?>



List of Articles
번호 제목 날짜 조회 수
300 간단한 캡차파일 만들기 captcha file 2023.01.12 312
299 콜론 연산자 2021.03.26 315
298 PHP웹 보안 취약점 TOP5(웹해킹) 2023.01.12 322
297 정규표현식 2021.03.26 326
296 PHP와 HTML과 자바스크립트의 관계 2021.03.26 333
295 PHP Notice: Use of undefined constant ... assumed ... 오류 2021.03.26 335
294 확장자 추출 하기 2021.03.26 337
293 문자열 함수 모음 2021.03.26 337
292 비교연산자 ( === 에 관해서 ) 2021.03.25 338
291 쿠키 확인 후 만료시 세션 파괴하는 방법 2020.11.23 342
290 특정일의 주차 구하기 2021.07.08 344
289 TIFF, GIF 여러장 변환 file 2021.03.26 346
288 복권 번호 뽑기 2021.03.26 358
287 curl을 이용하여 post, get 방식 으로 데이터 전송하기 2023.01.12 362
286 mysql_free_result(); 관련 오류 2021.03.25 371
285 AJAX로 해당 페이지에서 COOKIE 사용하기 2021.03.26 383
284 HEREDOC <<< ( PHP에서 echo로 HTML쉽게 표시하기 ) 2021.03.26 394
283 php 암호화 복호화 , 간단한 암호화 2023.01.12 412
282 문자,숫자 랜덤 출력 2021.03.26 413
281 php date 날짜 관련 함수 file 2021.03.27 428
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 17 Next
/ 17

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved