-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 928bb22
Showing
11 changed files
with
729 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
vendor | ||
.DS_Store | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# PHP images.weserv.nl | ||
|
||
This package provides a fluent PHP OOP builder for [images.weserv.nl](https://images.weserv.nl). | ||
|
||
## Installation | ||
|
||
You can install the package via composer: | ||
|
||
```bash | ||
composer require everzel/weserv-images-php | ||
``` | ||
|
||
## Usage | ||
|
||
```php | ||
use Everzel\WeservImages; | ||
use Everzel\Enums\Fit; | ||
|
||
$weserv = WeservImages::make('https://images.weserv.nl/lichtenstein.jpg', 'https://wsrv.nl', false); | ||
|
||
$url = $weserv | ||
->w(512) | ||
->h(512) | ||
->we() | ||
->fit(Fit::INSIDE->value); | ||
|
||
echo $url; | ||
``` | ||
|
||
### Or | ||
|
||
```php | ||
function weserv(string $imageUrl) { | ||
return WeservImages::make($imageUrl, 'https://wsrv.nl', false); | ||
} | ||
|
||
$url = weserv('https://images.weserv.nl/lichtenstein.jpg') | ||
->w(512) | ||
->h(512) | ||
->we() | ||
->fit(Fit::INSIDE->value); | ||
|
||
echo $url; | ||
``` | ||
|
||
![](https://images.weserv.nl/?w=512&h=512&we=1&fit=inside&url=https%3A%2F%2Fimages.weserv.nl%2Flichtenstein.jpg) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "everzel/weserv-php", | ||
"description": "Images.weserv.nl", | ||
"type": "library", | ||
"license": "MIT", | ||
"autoload": { | ||
"psr-4": { | ||
"Zelvad\\WeservPhp\\": "src/" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "everzel", | ||
"email": "vladislav.zelenyk@scalemeup.com" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"require": { | ||
"php": "^8.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Everzel\Concerns; | ||
|
||
use Everzel\Enums\Fit; | ||
|
||
trait InteractWithFitFormats | ||
{ | ||
public function fitCover(): self | ||
{ | ||
return $this->fit(Fit::COVER->value); | ||
} | ||
|
||
public function fitOutside(): self | ||
{ | ||
return $this->fit(Fit::OUTSIDE->value); | ||
} | ||
|
||
public function fitInside(): self | ||
{ | ||
return $this->fit(Fit::OUTSIDE->value); | ||
} | ||
|
||
public function fitContain(): self | ||
{ | ||
return $this->fit(Fit::CONTAIN->value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Everzel\Concerns; | ||
|
||
use Everzel\Enums\Output; | ||
|
||
trait InteractWithOutputFormats | ||
{ | ||
public function jpg(): self | ||
{ | ||
return $this->output(Output::JPG->value); | ||
} | ||
|
||
public function webp(): self | ||
{ | ||
return $this->output(Output::WEBP->value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Everzel\Enums; | ||
|
||
enum Alignment: string | ||
{ | ||
case CENTER = 'center'; | ||
case TOP = 'top'; | ||
case RIGHT = 'right'; | ||
case BOTTOM = 'bottom'; | ||
case LEFT = 'left'; | ||
case TOP_LEFT = 'top-left'; | ||
case BOTTOM_LEFT = 'bottom-left'; | ||
case BOTTOM_RIGHT = 'bottom-right'; | ||
case TOP_RIGHT = 'top-right'; | ||
case ENTROPY = 'entropy'; | ||
case ATTENTION = 'attention'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Everzel\Enums; | ||
|
||
enum Filter: string | ||
{ | ||
case DUOTONE = 'duotone'; | ||
case GREYSCALE = 'greyscale'; | ||
case SEPIA = 'sepia'; | ||
case NEGATE = 'negate'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Everzel\Enums; | ||
|
||
enum Fit: string | ||
{ | ||
case INSIDE = 'inside'; | ||
case OUTSIDE = 'outside'; | ||
case COVER = 'cover'; | ||
case FILL = 'fill'; | ||
case CONTAIN = 'contain'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Everzel\Enums; | ||
|
||
enum Mask: string | ||
{ | ||
case CIRCLE = 'circle'; | ||
case ELLIPSE = 'ellipse'; | ||
case TRIANGLE = 'triangle'; | ||
case TRIANGLE_180 = 'triangle-180'; | ||
case PENTAGON = 'pentagon'; | ||
case PENTAGON_180 = 'pentagon-180'; | ||
case HEXAGON = 'hexagon'; | ||
case SQUARE = 'square'; | ||
case STAR = 'star'; | ||
case HEART = 'heart'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Everzel\Enums; | ||
|
||
enum Output: string | ||
{ | ||
case JPG = 'jpg'; | ||
case PNG = 'png'; | ||
case GIF = 'gif'; | ||
case TIFF = 'tiff'; | ||
case WEBP = 'webp'; | ||
case JSON = 'json'; | ||
} |
Oops, something went wrong.