public function cropAndSaveImage($width = SimpleImage::WIDTH, $height = SimpleImage::HEIGHT, $path = SimpleImage::PATH, $filename = 'image', $type = IMAGETYPE_JPEG, $x1 = 0, $y1 = 0, $selection_width = 0, $selection_height = 0, $original_width = 0, $original_height = 0) { $this->validateImageFolder($path); $array_images = array(); $this->load(Yii::getPathOfAlias('webroot') . $path . $filename); $this->resize($original_width, $original_height); $new_image = imagecreatetruecolor($width, $height); imagecopyresampled($new_image, $this->image, 0, 0, $x1, $y1, $width, $height, $selection_width, $selection_height); $this->image = $new_image; $newFilename = $fileName = SecurityManager::generateHash() . '.jpg'; $this->save(Yii::getPathOfAlias('webroot') . $path . $newFilename, $type); array_push($array_images, $newFilename); return $array_images; }