Esempio n. 1
0
 public function actionCancel()
 {
     $id = Yii::$app->request->post('id');
     if (Yii::$app->request->isPost && $id != null) {
         return EditingPhotoActiveRecord::deleteEditingPhoto($id);
     }
     return false;
 }
 public static function photoEdit($id, $do, $kind)
 {
     $photo = EditingPhotoActiveRecord::find()->where(['id' => $id])->one();
     if ($kind == 'change' || $do == 'crop') {
         $image = EditingPhotoActiveRecord::changeEditingImage($do, $photo, $kind);
     } else {
         $image = new Imagick();
         $image->readImageBlob($photo['photo']);
     }
     if ($kind == 'filter') {
         $photo->filter = $do;
     }
     if ($do == 'reducenoise') {
         $photo->reduceNoise = $kind;
     }
     if ($do == 'blur') {
         $photo->blur = $kind;
     }
     if ($do == 'brightness') {
         $photo->brightness = $kind;
     }
     $photo->save();
     $image = EditingPhotoActiveRecord::filter($photo->filter, $image);
     if ($photo->reduceNoise != 0) {
         for ($i = 0; $i < $photo->reduceNoise; $i++) {
             foreach ($image as $frame) {
                 $frame->enhanceImage();
             }
         }
     }
     if ($photo->blur != 0) {
         foreach ($image as $frame) {
             $frame->blurImage($photo->blur, 5);
         }
     }
     if ($photo->brightness != 0) {
         foreach ($image as $frame) {
             $frame->modulateImage(100 + $photo->brightness, 100, 100);
         }
     }
     return $image->getImagesBlob();
 }
Esempio n. 3
0
 public function actionEdit($id)
 {
     $photo = PhotoActiveRecord::findOne($id);
     $editable = EditingPhotoActiveRecord::createEditingPhoto($photo->id);
     return $this->render('edit', ['photo' => $editable]);
 }