Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

incoqniski

Новичок
  
  • Posts

    3
  • Joined

  • Last visited

About incoqniski

  • Birthday 12/23/1988

Информация

  • Пол
    Мужлина
  • Город:
    Москва

incoqniski's Achievements

Newbie

Newbie (1/14)

  • First Post
  • Conversation Starter
  • Week One Done
  • One Month Later
  • One Year In

Recent Badges

0

Reputation

  1. Доброй ноли. Столкнулся с проблемой "белого фона". Думаю, эи проблема актуальна на сегодняшний гдень не только для меня. Наткнулся на один интересный код, который автоматически "подгоняет" загружаемые изображения под заданные критерии. Вопрос лишь в том, что не удаётся найти к каким именно критериям он обращается. По сути, он обрезает "белый фон" у картинки, но вместе с тем и урезает саму картинку и везгде получается разный размер. Был бы премного признателен за помощь в этом вопросе. public function resize($width = 0, $height = 0) { if (!$this->info['width'] || !$this->info['height']) { return; } $scale = max($width / $this->info['width'], $height / $this->info['height']); /* if ($scale == 1 && $this->info['mime'] != 'image/png') { return; }*/ //$new_width = (int)($this->info['width'] * $scale); //$new_height = (int)($this->info['height'] * $scale); $new_width=$width; $new_height=$height; $src_width=$new_width/$scale; $src_height=$new_height/$scale; $src_x=($this->info['width']-$src_width)/2; $src_y=($this->info['height']-$src_height)/2; $image_old = $this->image; //$this->image = imagecreatetruecolor($width, $height); // преобразуем, сохранив пропорции $this->image = imagecreatetruecolor($new_width, $new_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, 0, 0, $src_x, $src_y, $new_width, $new_height, $src_width, $src_height); //imagecopyresampled($this->image, $image_old, $xpos, $ypos, 0, 0, $new_width, $new_height, $new_width, $new_height); imagedestroy($image_old); //$this->info['width'] = $width; // $this->info['height'] = $height; $this->info['width'] = $new_width; $this->info['height'] = $new_height; }

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.