Mohammad Khazaee
2 years ago
18 changed files with 258 additions and 94 deletions
-
23app/Http/Controllers/FileController.php
-
2app/Http/Controllers/Traits/FileTrait.php
-
2app/Http/Middleware/BindCollectionModelMiddleware.php
-
12app/Http/Middleware/BindFileModelMiddleware.php
-
5app/Http/Requests/FileStoreRequest.php
-
126app/Image/ImageProcessor.php
-
30app/Image/Traits/ModulateTrait.php
-
5app/Models/Collection.php
-
14app/Models/File.php
-
4routes/api.php
-
1storage/framework/.gitignore
-
BINstorage/stub/image1.png
-
BINstorage/stub/image2.jpeg
-
BINstorage/stub/image3.png
-
21tests/Feature/FileDeleteTest.php
-
20tests/Feature/FileShowTest.php
-
34tests/Feature/FileStoreTest.php
-
21tests/Feature/FileUpdateTest.php
@ -0,0 +1,30 @@ |
|||
<?php |
|||
|
|||
namespace App\Image\Traits; |
|||
|
|||
use Jcupitt\Vips\Interpretation; |
|||
|
|||
trait ModulateTrait { |
|||
public function brightness($image, float $brightness = 1.0, float $saturation = 1.0, float $hue = 0.0) |
|||
{ |
|||
$oldInterpretation = $image->interpretation; |
|||
$hue %= 360; |
|||
if ($hue < 0) { |
|||
$hue = 360 + $hue; |
|||
} |
|||
if ($image->hasAlpha()) { |
|||
$imageWithoutAlpha = $image->extract_band(0, ['n' => $image->bands - 1]); |
|||
$alpha = $image->extract_band($image->bands - 1, ['n' => 1]); |
|||
return $imageWithoutAlpha |
|||
->colourspace(Interpretation::LCH) |
|||
->linear([$brightness, $saturation, 1.0], [0.0, 0.0, $hue]) |
|||
->colourspace($oldInterpretation) |
|||
->bandjoin($alpha); |
|||
} |
|||
return $image |
|||
->colourspace(Interpretation::LCH) |
|||
->linear([$brightness, $saturation, 1.0], [0.0, 0.0, $hue]) |
|||
->colourspace($oldInterpretation); |
|||
} |
|||
|
|||
} |
Binary file not shown.
After Width: 600 | Height: 1200 | Size: 620 KiB |
Binary file not shown.
After Width: 720 | Height: 1204 | Size: 124 KiB |
Binary file not shown.
After Width: 423 | Height: 750 | Size: 42 KiB |
@ -0,0 +1,21 @@ |
|||
<?php |
|||
|
|||
namespace Tests\Feature; |
|||
|
|||
use Illuminate\Foundation\Testing\RefreshDatabase; |
|||
use Illuminate\Foundation\Testing\WithFaker; |
|||
use Tests\TestCase; |
|||
|
|||
class FileDeleteTest extends TestCase |
|||
{ |
|||
/** |
|||
* A basic feature test example. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function test_example() |
|||
{ |
|||
$this->assertTrue(true); |
|||
|
|||
} |
|||
} |
@ -0,0 +1,20 @@ |
|||
<?php |
|||
|
|||
namespace Tests\Feature; |
|||
|
|||
use Illuminate\Foundation\Testing\RefreshDatabase; |
|||
use Illuminate\Foundation\Testing\WithFaker; |
|||
use Tests\TestCase; |
|||
|
|||
class FileShowTest extends TestCase |
|||
{ |
|||
/** |
|||
* A basic feature test example. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function test_example() |
|||
{ |
|||
$this->assertTrue(true); |
|||
} |
|||
} |
@ -0,0 +1,21 @@ |
|||
<?php |
|||
|
|||
namespace Tests\Feature; |
|||
|
|||
use Illuminate\Foundation\Testing\RefreshDatabase; |
|||
use Illuminate\Foundation\Testing\WithFaker; |
|||
use Tests\TestCase; |
|||
|
|||
class FileUpdateTest extends TestCase |
|||
{ |
|||
/** |
|||
* A basic feature test example. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function test_example() |
|||
{ |
|||
$this->assertTrue(true); |
|||
|
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue