Codeigniter의 이미지 조작 라이브러리를 사용하여 업로드 된 이미지의 크기를 작게, 크게, 크게로 3 가지로 조정합니다.Codeigniter 이미지 조작 클래스는 이미지 크기를 조정하는 동안 이미지를 회전합니다.
리사이징이 잘 작동합니다. 그러나 세로 이미지의 크기를 조정하면 라이브러리가 이미지를 가로로 회전합니다.
이 자리에서 내가 가지고있는 구성 설정은 다음과 같습니다
$this->resize_config['image_library'] = 'gd2';
$this->resize_config['source_image'] = $this->file_data['full_path'];
$this->resize_config['maintain_ratio'] = TRUE;
// These change based on the type (small, normal, large)
$this->resize_config['new_image'] = './uploads/large/'.$this->new_file_name.'.jpg';
$this->resize_config['width'] = 432;
$this->resize_config['height'] = 288;
기본이 내가 원하는 무엇 인 자동으로 설정하기 때문에이 master_dim 속성을 설정하고 있지 않다.
제 가정은 라이브러리가 세로 이미지를 가져 와서 높이가 너비보다 크고 높이/너비 구성을 적절하게 변환하여 이미지가 세로로 유지된다는 것입니다.
어떤 일이 일어나고 있는지 (분명히) 라이브러리는 이미지가 수직 일 때 이미지를 회전시키고 구성별로 크기를 조정합니다.
log_message('debug', 'attempting '.$size.' photo resize');
$this->CI->load->library('image_lib');
$this->CI->image_lib->initialize($this->resize_config);
if ($this->CI->image_lib->resize())
{
$return_value = TRUE;
log_message('debug', $size.' photo resize successful');
}
else
{
$this->errors[] = $this->CI->image_lib->display_errors();
log_message('debug', $size.' photo resize failed');
}
$this->CI->image_lib->clear();
return $return_value;
편집
나는 문제가 업로드 라이브러리에서 할 수있다 생각한다
이
내가 실제 재 크기 조정을 할 필요가 장소에 코드입니다. 업로드에서 image_height 및 image_width를 다시 가져올 때 세로 이미지를 업로드했지만 너비가 더 커진 것처럼 보입니다. 이 로그의 결과입니다 $this->is_vertical = $this->file_data['image_height'] > $this->file_data['image_width'];
log_message('debug', 'image height:'.$this->file_data['image_height']);
log_message('debug', 'image width:'.$this->file_data['image_width']);
if ($this->is_vertical)
{
$this->resize_config['master_dim'] = 'height';
}
else
{
$this->resize_config['master_dim'] = 'width';
}
log_message('debug', 'master_dim setting:'.$this->resize_config['master_dim']);
: 내가 값을 확인하는 몇 가지 로깅을 추가
$this->upload_config['allowed_types'] = 'jpg|jpeg';
$this->upload_config['max_size'] = '2000';
$this->upload_config['max_width'] = '0';
$this->upload_config['max_height'] = '0';
$this->upload_config['upload_path'] = './uploads/working/';
$this->CI->load->library('upload', $this->upload_config);
if ($this->CI->upload->do_upload($this->posted_file))
{
$this->file_data = $this->CI->upload->data();
$return_value = TRUE;
log_message('debug', 'upload successful');
}
:
이
내가 사진을 업로드하기 위해 사용하고 코드의 일부입니다 :DEBUG - 2010-03-16 18시 35분 6초 -> 상 높이 : 1,536 DEBUG - 2010-03-16 18시 35분 6초 -> 화상 폭 : 2,048 DEBUG - 2010-03 -16 18:35:06 -> master_dim 설정 : 포토샵에서 이미지를 보면 폭
, 이러한 치수는 다음과 같습니다
높이 : 2048 폭 : 1536
누구나 업로드 라이브러리가이 작업을 수행하는 원인이 될 수 있습니다 알고 ?
다행스럽게 생각합니다. 다음 비트를 알아내는 것만으로 좋은 표정! – musoNic80
최종 사용자가 동일한 작업을 수행하지 못하도록 보호하는 좋은 방법을 알고 있습니까? 나는 똑같은 문제를 겪고있다. 이미지는 오른쪽으로 보이지만 사파리에서 열면 옆쪽으로 보입니다. – Catfish
나는 이것을하는 좋은 방법을 찾지 못했지만 솔직히 말해서 나는 그것에 많은 시간을 투자하지 않았다. – someoneinomaha