public function setCropeImage($img, $coords) { $newImage = str_replace('.', '_resize.', $img); $config = array('image_library' => 'gd2', 'source_image' => '.' . $img, 'new_image' => '.' . $newImage, 'width' => $coords['w'], 'height' => $coords['h'], 'maintain_ratio' => FALSE, 'x_axis' => $coords['x'], 'y_axis' => $coords['y']); $this->image_lib->initialize($config); if ($this->image_lib->crop()) { $this->users_model->saveCropImgForUser(Current_user::getIdUser(), $newImage); return '<img src="' . $newImage . '?' . time() . '" />'; } else { return FALSE; } }