public function resize($targetPath) { if (isset($this->param->size['height']) && isset($this->param->size['width'])) { $h = $this->param->size['height']; $w = $this->param->size['width']; $image = new ImageProcessor(); $image->load($targetPath); $image->resize($w, $h); // (filename, image type, jpeg compression, permissions); $image->save($targetPath, null, $this->param->compression); } }
public function resize($targetPath) { if (isset($this->param->size['height']) && isset($this->param->size['width'])) { $h = intval($this->param->size['height']); $w = intval($this->param->size['width']); $image = new ImageProcessor(); $image->load($targetPath); $size = getimagesize($targetPath); if ($size[0] > $w || $size[1] > $h) { $image->cropOuterAndScale($w, $h); } $image->save($targetPath, null, $this->param->compression); } }
public function resize($targetPath) { if ($this->param->resizeHeight) { $maxHeight = $this->param->resizeHeight; } elseif (isset($this->param->size['height'])) { $maxHeight = $this->param->size['height']; } if ($maxHeight) { $image = new ImageProcessor(); $image->load($targetPath); // we should only resize image file only when size is changed. if ($image->getHeight() > $maxHeight) { $image->resizeToHeight($maxHeight); // (filename, image type, jpeg compression, permissions); $image->save($targetPath, null, $this->param->compression); } } }
public function resize($targetPath) { if ($this->param->resizeWidth) { $maxWidth = $this->param->resizeWidth; } else { if (isset($this->param->size['width'])) { $maxWidth = $this->param->size['width']; } } if ($maxWidth) { $image = new ImageProcessor(); $image->load($targetPath); // we should only resize image file only when size is changed. if ($image->getWidth() > $maxWidth) { $image->resizeToWidth($maxWidth); // (filename, image type, jpeg compression, permissions); $image->save($targetPath, null, $this->param->compression); } } }