public function uploadImage($fieldName = "upload", $folder = "upload/", $width = null, $height = null) { $output = $this->upload($fieldName, $folder); $path = $output["url"]; $img = new Image($path); if ($width == null && $height == null) { return $output; } else { if ($width == null) { $img->fitToHeight($height); } else { if ($height == null) { $img->fitToWidth($width); } else { $img = $img->resize($width, $height); } } } $img->save(); return $output; }