File tree Expand file tree Collapse file tree 1 file changed +20
-6
lines changed
src/Charcoal/Image/Effect Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -470,12 +470,26 @@ public function process(array $data = null)
470
470
);
471
471
472
472
case 'fill ' :
473
- $ imgClass = get_class ($ this ->image ());
474
- $ canvas = new $ imgClass ;
475
- $ canvas ->create ($ this ->width (), $ this ->width (), $ this ->backgroundColor ());
476
- throw new Exception (
477
- 'Crop resize mode is not (yet) supported '
478
- );
473
+ $ newWidth = $ this ->width ();
474
+ $ newHeight = $ this ->height ();
475
+
476
+ $ oldRatio = ($ imageWidth / $ imageHeight );
477
+ $ newRatio = ($ newWidth / $ newHeight );
478
+
479
+ if ($ newRatio > $ oldRatio ) {
480
+ $ newHeight = ($ imageHeight * $ this ->width () / $ imageWidth );
481
+ } else {
482
+ $ newWidth = ($ imageWidth * $ this ->height () / $ imageHeight );
483
+ }
484
+
485
+ $ this ->doResize ($ newWidth , $ newHeight );
486
+
487
+ // $imgClass = get_class($this->image());
488
+ // $canvas = new $imgClass;
489
+ // $canvas->create($this->width(), $this->width(), $this->backgroundColor());
490
+ // throw new Exception(
491
+ // 'Crop resize mode is not (yet) supported'
492
+ // );
479
493
}
480
494
481
495
return $ this ;
You can’t perform that action at this time.
0 commit comments