From c21432f3426c5d93b89570eeb4d5aadcc2a075fc Mon Sep 17 00:00:00 2001 From: kazik Date: Tue, 15 Mar 2016 10:20:46 +0100 Subject: [PATCH] Adding support for watermarks --- README.md | 16 +++++++++++++++ config/clyde.php | 20 +++++++++++++++++++ src/Http/Controllers/ClydeImageController.php | 2 ++ 3 files changed, 38 insertions(+) diff --git a/README.md b/README.md index ba3a7cd..4838b09 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,22 @@ Additionally, you can setup presets and use them as a quicker way to apply manip ``` +## Watermarks + +Watermarks are stored on the local filesystem by default. To use watermarks put the watermark files +in `storage/app/watermarks` directory. To adjust the location where watermark files are stored you can +edit `watermarks` and `watermarks_path_prefix` entries in the config. + +``` +ClydeImage::url('56a1472beca5d.jpg', [ + 'mark' => 'watermark.png', + 'markpos' => 'top-right', + 'markw' => '50', + 'markh' => '50', + 'markpad' => '10' +]); +``` + ## Security All URLs generated by Clyde are signed by default. This means that there is always a signature diff --git a/config/clyde.php b/config/clyde.php index cfe7b01..e3e14f4 100644 --- a/config/clyde.php +++ b/config/clyde.php @@ -22,6 +22,16 @@ */ 'cache' => 'local', + /* + |-------------------------------------------------------------------------- + | Watermarks Filesystem + |-------------------------------------------------------------------------- + | + | Please specify watermarks filesystem (local or s3). + | + */ + 'watermarks' => 'local', + /* |-------------------------------------------------------------------------- | Source Path Prefix @@ -42,6 +52,16 @@ */ 'cache_path_prefix' => '/uploads/.cache', + /* + |-------------------------------------------------------------------------- + | Watermarks Path Prefix + |-------------------------------------------------------------------------- + | + | This is a path where watermarks will be stored. + | + */ + 'watermarks_path_prefix' => '/watermarks', + /* |-------------------------------------------------------------------------- | Max Image Size diff --git a/src/Http/Controllers/ClydeImageController.php b/src/Http/Controllers/ClydeImageController.php index 650c3cf..c64418b 100644 --- a/src/Http/Controllers/ClydeImageController.php +++ b/src/Http/Controllers/ClydeImageController.php @@ -47,8 +47,10 @@ public function show(Request $request, $filename) $server = ServerFactory::create([ 'source' => $this->files->disk(config('clyde.source'))->getDriver(), 'cache' => $this->files->disk(config('clyde.cache'))->getDriver(), + 'watermarks' => $this->files->disk(config('clyde.watermarks'))->getDriver(), 'source_path_prefix' => config('clyde.source_path_prefix'), 'cache_path_prefix' => config('clyde.cache_path_prefix'), + 'watermarks_path_prefix' => config('clyde.watermarks_path_prefix'), 'max_image_size' => config('clyde.max_image_size'), 'presets' => config('clyde.presets'), 'response' => new SymfonyResponseFactory()