Browse Source

added effects to front; resize image before applying effect

develop
Robin Thoni 8 years ago
parent
commit
d9dea72a9d

+ 2
- 0
app/Http/Business/EffectsBusiness.php View File

27
             self::notFound("Effect does not exist");
27
             self::notFound("Effect does not exist");
28
         }
28
         }
29
 
29
 
30
+        ImagesBusiness::prepareImage($data->getImage());
31
+
30
         /**
32
         /**
31
          * @var $filter AbstractFilter
33
          * @var $filter AbstractFilter
32
          */
34
          */

+ 8
- 2
app/Http/Business/ImagesBusiness.php View File

42
         echo file_get_contents($dbo->getPath());
42
         echo file_get_contents($dbo->getPath());
43
         exit;
43
         exit;
44
     }
44
     }
45
+    
46
+    public static function prepareImage(\Imagick $image)
47
+    {
48
+        $image->scaleImage(420, 420, true);
49
+        $image->setImageFormat(self::IMAGES_FORMAT);
50
+    }
45
 
51
 
46
     public static function upload(ImageUploadDbo $image, LuticateUsersDbo $_user)
52
     public static function upload(ImageUploadDbo $image, LuticateUsersDbo $_user)
47
     {
53
     {
55
         if (is_null($dbo->getName()) || $dbo->getName() === "") {
61
         if (is_null($dbo->getName()) || $dbo->getName() === "") {
56
             $dbo->setName(Carbon::now()->toW3cString());
62
             $dbo->setName(Carbon::now()->toW3cString());
57
         }
63
         }
64
+        
65
+        self::prepareImage($image->getImage());
58
 
66
 
59
-        $image->getImage()->scaleImage(420, 420, true);
60
-        $image->getImage()->setImageFormat(self::IMAGES_FORMAT);
61
         try
67
         try
62
         {
68
         {
63
             $image->getImage()->writeImage($path);
69
             $image->getImage()->writeImage($path);

+ 11
- 0
public/app/controllers/upload.controller.js View File

3
         function($scope, $state, $mdDialog, EffectsBusiness, ImagesBusiness, luticateAuthCache, errorDialogMd) {
3
         function($scope, $state, $mdDialog, EffectsBusiness, ImagesBusiness, luticateAuthCache, errorDialogMd) {
4
 
4
 
5
             $scope.image = null;
5
             $scope.image = null;
6
+
7
+            $scope.effects = [
8
+                {
9
+                    name: "Black and White",
10
+                    id: "BlackAndWhite"
11
+                },
12
+                {
13
+                    name: "GrayScale",
14
+                    id: "GrayScale"
15
+                }
16
+            ];
6
             
17
             
7
             var promiseImage = {
18
             var promiseImage = {
8
                 id: "promiseImage",
19
                 id: "promiseImage",

+ 5
- 0
public/app/views/upload.html View File

1
 <div layout="column" layout-fill layout-align="top center">
1
 <div layout="column" layout-fill layout-align="top center">
2
 
2
 
3
     <h1>Upload</h1>
3
     <h1>Upload</h1>
4
+
5
+    <div class="col-xs12" ng-show="image != null">
6
+        <md-button ng-repeat="effect in effects" ng-click="applyEffect(effect.id, null)">{{effect.name}}</md-button>
7
+    </div>
8
+
4
     <div ng-show="isUploadVisible()" class="col-xs-6" lu-busy="imageView">
9
     <div ng-show="isUploadVisible()" class="col-xs-6" lu-busy="imageView">
5
 
10
 
6
         <div class="center-block">
11
         <div class="center-block">

Loading…
Cancel
Save