Content-Length: 438786 | pFad | http://github.com/everzel/weserv-images-php/commit/928bb22d8ca0a50d8c739223b2a0393638842c85

92 init · everzel/weserv-images-php@928bb22 · GitHub
Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
everzel committed Jun 25, 2023
0 parents commit 928bb22
Show file tree
Hide file tree
Showing 11 changed files with 729 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vendor
.DS_Store
.idea
47 changes: 47 additions & 0 deletions README.md
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)

21 changes: 21 additions & 0 deletions composer.json
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"
}
}
28 changes: 28 additions & 0 deletions src/Concerns/InteractWithFitFormats.php
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);
}
}
18 changes: 18 additions & 0 deletions src/Concerns/InteractWithOutputFormats.php
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);
}
}
18 changes: 18 additions & 0 deletions src/Enums/Alignment.php
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';
}
11 changes: 11 additions & 0 deletions src/Enums/Filter.php
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';
}
12 changes: 12 additions & 0 deletions src/Enums/Fit.php
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';
}
17 changes: 17 additions & 0 deletions src/Enums/Mask.php
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';
}
13 changes: 13 additions & 0 deletions src/Enums/Output.php
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';
}
Loading

0 comments on commit 928bb22

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/everzel/weserv-images-php/commit/928bb22d8ca0a50d8c739223b2a0393638842c85

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy