| 제목 | image_lib의 resize() 질문 입니다. | ||
|---|---|---|---|
| 글쓴이 | 양승현 | 작성시각 | 2010/12/28 11:11:55 |
|
|
|||
|
image_lib라이브러리의 resize()함수를 사용하여 이미지 업로드시에 설정한값이 있으면 해당 이미지 사이즈로 원본 이미지를 줄이려고 합니다. (서버공간 문제, 뷰페이지 이미지 넘침 문제) master_dim 설정값을 auto인 상태로 이미지를 생성할때 문제가 되고 있네요. master_dim이 auto인 상태에서 세로가 긴 이미지의 경우 세로축을 기준으로 잘 줄여지는데.. 가로가 긴이미지의 경우 세로축을 기준으로 이미지가 줄여지네요. 같은 문제에 봉착하신분 계신가요? |
|||
| 다음글 | url관련 질문입니다. (2) | ||
| 이전글 | ci로 모바일 페이지 구축하기 (2) | ||
|
변종원(웅파)
/
2010/12/28 21:06:40 /
추천
0
|
|
양승현
/
2010/12/29 12:55:37 /
추천
0
음...$ratio가 있었군요.. ㅎㅎ
|
function image_reproportion() { if ( ! is_numeric($this->width) OR ! is_numeric($this->height) OR $this->width == 0 OR $this->height == 0) return; if ( ! is_numeric($this->orig_width) OR ! is_numeric($this->orig_height) OR $this->orig_width == 0 OR $this->orig_height == 0) return; $new_width = ceil($this->orig_width*$this->height/$this->orig_height); $new_height = ceil($this->width*$this->orig_height/$this->orig_width); $ratio = (($this->orig_height/$this->orig_width) - ($this->height/$this->width)); if ($this->master_dim != 'width' AND $this->master_dim != 'height') { $this->master_dim = ($ratio < 0) ? 'width' : 'height'; } if (($this->width != $new_width) AND ($this->height != $new_height)) { if ($this->master_dim == 'height') { $this->width = $new_width; } else { $this->height = $new_height; } } }이미지 라이브러리중 $ratio에 따라 강제로 $this->master_dim 을 할당하는데 올린 이미지의$ratio를 계산해보세요.