저는 OpenCart에서 이미지 크기를 조정할 수있는 방법을 살펴 보았지만 아무 것도 찾지 못했습니다.OpenCart에서 이미지 크기 조정 비율을 제거하십시오
크기를 조정해야하지만 비율을 유지하지 않아야합니다. 이미지를 설정하는 것과 같습니다.
여기에 시스템/라이브러리/image.php 내가 그렇게 이미지가 크기 조정에 대한 비율입니다 보관하지 않습니다 제거 할 수있는 코드에서 어떤
public function resize($width = 0, $height = 0) {
if (!$this->info['width'] || !$this->info['height']) {
return;
}
$xpos = 0;
$ypos = 0;
$scale = min($width/$this->info['width'], $height/$this->info['height']);
if ($scale == 1) {
return;
}
$new_width = (int)($this->info['width'] * $scale);
$new_height = (int)($this->info['height'] * $scale);
$xpos = (int)(($width - $new_width)/2);
$ypos = (int)(($height - $new_height)/2);
$image_old = $this->image;
$this->image = imagecreatetruecolor($width, $height);
if (isset($this->info['mime']) && $this->info['mime'] == 'image/png') {
imagealphablending($this->image, false);
imagesavealpha($this->image, true);
$background = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
imagecolortransparent($this->image, $background);
} else {
$background = imagecolorallocate($this->image, 255, 255, 255);
}
imagefilledrectangle($this->image, 0, 0, $width, $height, $background);
imagecopyresampled($this->image, $image_old, $xpos, $ypos, 0, 0, $new_width, $new_height, $this->info['width'], $this->info['height']);
imagedestroy($image_old);
$this->info['width'] = $width;
$this->info['height'] = $height;
}
의 크기 조정 코드는?
내게 잘 맞습니다 (OpenCart 1.5.2.1). 이 코드를 게시 해 주셔서 감사합니다. – andrew
OpenCart의 새 버전이 필요하기 때문에 고마워요, 작동합니다. model/tool/image.php의 마지막 else if 문을 변경했습니다. "return HTTPS_IMAGE. $ new_image;"대신 " 나는 "반환 $ this-> config-> get ('config_ssl'). 'image /'. $ new_image;"를 사용했습니다. 그리고 효과가있었습니다. – nikoloza
이 방법이 효과가 있었지만 크기를 조정하거나 자르기 만하는 방법은 무엇입니까? – NewCod3r