-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add generate composer script; add more tests; add docs
- Loading branch information
Victor Bolshov
committed
Sep 10, 2021
1 parent
bc939e8
commit 912d93a
Showing
6 changed files
with
219 additions
and
3 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
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 |
---|---|---|
|
@@ -24,5 +24,8 @@ | |
"psr-4": { | ||
"Imgproxy\\Test\\": "test/" | ||
} | ||
}, | ||
"scripts": { | ||
"generate": "Imgproxy\\CLI::generate" | ||
} | ||
} |
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 @@ | ||
version: "3.7" | ||
services: | ||
imgproxy: | ||
image: darthsim/imgproxy:latest | ||
environment: | ||
IMGPROXY_KEY: "943b421c9eb07c830af81030552c86009268de4e532ba2ee2eab8247c6da0881" | ||
IMGPROXY_SALT: "520f986b998545b4785e0defbc4f3c1203f22de2374a3d53cb7a7fe9fea309c5" | ||
IMGPROXY_LOCAL_FILESYSTEM_ROOT: "/opt/images" | ||
ports: | ||
- 8080:8080 | ||
volumes: | ||
- ./test/sample/sample_640×426.jpeg:/opt/images/file.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,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Imgproxy; | ||
|
||
use Composer\Script\Event; | ||
|
||
class CLI | ||
{ | ||
public static function generate(Event $event) | ||
{ | ||
$opts = $event->getArguments(); | ||
$base = null; | ||
$key = null; | ||
$salt = null; | ||
$source = null; | ||
$width = 0; | ||
$height = 0; | ||
$advanced = false; | ||
for ($i = 0; $i < count($opts); $i++) { | ||
$name = $opts[$i]; | ||
$name = ltrim($name, "-"); | ||
switch ($name) { | ||
case "base": | ||
$base = $opts[++$i]; | ||
break; | ||
case "key": | ||
$key = $opts[++$i]; | ||
break; | ||
case "salt": | ||
$salt = $opts[++$i]; | ||
break; | ||
case "source": | ||
$source = $opts[++$i]; | ||
break; | ||
case "width": | ||
$width = $opts[++$i]; | ||
break; | ||
case "height": | ||
$height = $opts[++$i]; | ||
break; | ||
case "advanced": | ||
$advanced = true; | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
$builder = new UrlBuilder($base, $key, $salt); | ||
$url = new Url($builder, $source, $width, $height); | ||
if ($advanced) { | ||
$url->useAdvancedMode(); | ||
} | ||
echo $url->toString() . "\n"; | ||
} | ||
} |
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
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