Permalink
Browse files

Added remapImage function. Tidied code.

1 parent 0dfd81a commit 3313b422d4d9c2dba8c1aed4071937f6c220f3c8 @Danack committed Apr 30, 2016
Showing with 2,439 additions and 2,153 deletions.
  1. +49 −84 bin/cli.php
  2. +50 −0 bin/cliInjectionParams.php
  3. +1 −1 composer.json
  4. +30 −27 composer.lock
  5. +39 −0 data/config_template/letsencrypt.config.ini.php
  6. +41 −0 data/config_template/letsencrypt.nginx.conf.php
  7. +1 −1 data/config_template/php.ini.php
  8. BIN imagick/images/NetscapeWebSafeColours.gif
  9. BIN imagick/images/VGA_palette_with_black_borders.png
  10. +3 −0 scripts/deployAsUser.sh
  11. +1 −0 scripts/letsencrypt.sh
  12. +264 −0 src/ImagickDemo/App.php
  13. +57 −0 src/ImagickDemo/ConsoleApplication.php
  14. +6 −6 src/ImagickDemo/Control/ControlComposite.php
  15. +6 −6 src/ImagickDemo/Control/NullControl.php
  16. +35 −0 src/ImagickDemo/ControlElement/DitherMethod.php
  17. +23 −15 src/ImagickDemo/Controller/Image.php
  18. +5 −4 src/ImagickDemo/Controller/Page.php
  19. +2 −1 src/ImagickDemo/Controller/QueueInfo.php
  20. +4 −5 src/ImagickDemo/Controller/ServerInfo.php
  21. +63 −0 src/ImagickDemo/Display.php
  22. +142 −353 src/ImagickDemo/DocHelper.php
  23. +4 −6 src/ImagickDemo/DocHelperDisplay.php
  24. +2 −2 src/ImagickDemo/Example.php
  25. +20 −0 src/ImagickDemo/Helper/PageInfo.php
  26. +84 −0 src/ImagickDemo/Image.php
  27. +40 −0 src/ImagickDemo/ImageCachePath.php
  28. +153 −0 src/ImagickDemo/ImageGenerator.php
  29. +0 −22 src/ImagickDemo/Imagick/OriginalImageFile.php
  30. +9 −1 src/ImagickDemo/Imagick/adaptiveBlurImage.php
  31. +1 −1 src/ImagickDemo/Imagick/adaptiveSharpenImage.php
  32. +9 −1 src/ImagickDemo/Imagick/adaptiveThresholdImage.php
  33. +9 −1 src/ImagickDemo/Imagick/addNoiseImage.php
  34. +9 −1 src/ImagickDemo/Imagick/annotateImage.php
  35. +9 −1 src/ImagickDemo/Imagick/autoLevelImage.php
  36. +9 −1 src/ImagickDemo/Imagick/blackThresholdImage.php
  37. +9 −1 src/ImagickDemo/Imagick/blueShiftImage.php
  38. +9 −1 src/ImagickDemo/Imagick/blurImage.php
  39. +9 −1 src/ImagickDemo/Imagick/brightnessContrastImage.php
  40. +9 −1 src/ImagickDemo/Imagick/charcoalImage.php
  41. +9 −1 src/ImagickDemo/Imagick/colorMatrixImage.php
  42. +9 −1 src/ImagickDemo/Imagick/colorizeImage.php
  43. +9 −1 src/ImagickDemo/Imagick/contrastImage.php
  44. +9 −1 src/ImagickDemo/Imagick/convolveImage.php
  45. +6 −3 src/ImagickDemo/Imagick/deskewImage.php
  46. +9 −1 src/ImagickDemo/Imagick/despeckleImage.php
  47. +9 −1 src/ImagickDemo/Imagick/edgeImage.php
  48. +9 −1 src/ImagickDemo/Imagick/embossImage.php
  49. +9 −1 src/ImagickDemo/Imagick/enhanceImage.php
  50. +9 −1 src/ImagickDemo/Imagick/equalizeImage.php
  51. +9 −1 src/ImagickDemo/Imagick/exportImagePixels.php
  52. +9 −1 src/ImagickDemo/Imagick/filter.php
  53. +5 −4 src/ImagickDemo/Imagick/floodFillPaintImage.php
  54. +6 −4 src/ImagickDemo/Imagick/functionImage.php
  55. +243 −17 src/ImagickDemo/Imagick/functions.php
  56. +9 −1 src/ImagickDemo/Imagick/gammaImage.php
  57. +9 −1 src/ImagickDemo/Imagick/gaussianBlurImage.php
  58. +9 −1 src/ImagickDemo/Imagick/haldClutImage.php
  59. +3 −1 src/ImagickDemo/Imagick/identifyFormat.php
  60. +9 −1 src/ImagickDemo/Imagick/implodeImage.php
  61. +9 −1 src/ImagickDemo/Imagick/linearStretchImage.php
  62. +9 −1 src/ImagickDemo/Imagick/medianFilterImage.php
  63. +9 −1 src/ImagickDemo/Imagick/modulateImage.php
  64. +19 −23 src/ImagickDemo/Imagick/morphology.php
  65. +9 −1 src/ImagickDemo/Imagick/motionBlurImage.php
  66. +9 −1 src/ImagickDemo/Imagick/negateImage.php
  67. +9 −1 src/ImagickDemo/Imagick/normalizeImage.php
  68. +9 −1 src/ImagickDemo/Imagick/oilPaintImage.php
  69. +4 −5 src/ImagickDemo/Imagick/opaquePaintImage.php
  70. +9 −1 src/ImagickDemo/Imagick/orderedPosterizeImage.php
  71. +9 −1 src/ImagickDemo/Imagick/posterizeImage.php
  72. +10 −1 src/ImagickDemo/Imagick/quantizeImage.php
  73. +10 −1 src/ImagickDemo/Imagick/queryFontMetrics.php
  74. +10 −1 src/ImagickDemo/Imagick/radialBlurImage.php
  75. +10 −1 src/ImagickDemo/Imagick/reduceNoiseImage.php
  76. +10 −1 src/ImagickDemo/Imagick/remapImage.php
  77. +10 −1 src/ImagickDemo/Imagick/rollImage.php
  78. +10 −1 src/ImagickDemo/Imagick/rotationalBlurImage.php
  79. +10 −1 src/ImagickDemo/Imagick/roundCorners.php
  80. +9 −1 src/ImagickDemo/Imagick/selectiveBlurImage.php
  81. +9 −1 src/ImagickDemo/Imagick/setCompressionQuality.php
  82. +9 −1 src/ImagickDemo/Imagick/setImageCompressionQuality.php
  83. +14 −14 src/ImagickDemo/Imagick/setSamplingFactors.php
  84. +9 −1 src/ImagickDemo/Imagick/shadeImage.php
  85. +9 −1 src/ImagickDemo/Imagick/sharpenImage.php
  86. +10 −1 src/ImagickDemo/Imagick/sigmoidalContrastImage.php
  87. +10 −1 src/ImagickDemo/Imagick/sketchImage.php
  88. +9 −1 src/ImagickDemo/Imagick/solarizeImage.php
  89. +9 −1 src/ImagickDemo/Imagick/spreadImage.php
  90. +9 −1 src/ImagickDemo/Imagick/statisticImage.php
  91. +9 −1 src/ImagickDemo/Imagick/swirlImage.php
  92. +9 −1 src/ImagickDemo/Imagick/thresholdImage.php
  93. +4 −4 src/ImagickDemo/Imagick/transparentPaintImage.php
  94. +9 −1 src/ImagickDemo/Imagick/unsharpMaskImage.php
  95. +9 −1 src/ImagickDemo/Imagick/vignetteImage.php
  96. +9 −1 src/ImagickDemo/Imagick/waveImage.php
  97. +9 −1 src/ImagickDemo/Imagick/whiteThresholdImage.php
  98. +5 −3 src/ImagickDemo/ImagickKernel/addUnityKernel.php
  99. +2 −1 src/ImagickDemo/ImagickKernel/fromBuiltin.php
  100. +16 −1 src/ImagickDemo/ImagickKernel/fromMatrix.php
  101. +3 −1 src/ImagickDemo/ImagickKernel/getMatrix.php
  102. +6 −4 src/ImagickDemo/ImagickKernel/scale.php
  103. +3 −1 src/ImagickDemo/ImagickKernel/separate.php
  104. +0 −482 src/ImagickDemo/ImagickKernel/usage.php
  105. +0 −1 src/ImagickDemo/Model/QueueInfo.php
  106. +4 −1 src/ImagickDemo/Navigation/CategoryInfo.php
  107. +3 −1 src/ImagickDemo/Queue/ImagickTask.php
  108. +148 −102 src/ImagickDemo/Queue/ImagickTaskRunner.php
  109. +2 −3 src/ImagickDemo/Queue/RedisTaskQueue.php
  110. +104 −0 src/ImagickDemo/Route.php
  111. +7 −7 src/ImagickDemo/Tutorial/backgroundMasking.php
  112. +2 −1 src/ImagickDemo/Tutorial/creatingGifs.php
  113. +1 −1 src/ImagickDemo/Tutorial/functions.php
  114. +3 −2 src/ImagickDemo/Tutorial/gradientGeneration.php
  115. +0 −717 src/appFunctions.php
  116. +0 −110 src/cliFunctions.php
  117. +97 −0 src/httpInjectionParams.php
  118. +29 −15 src/index.php
  119. +32 −28 src/injectionParams.php
  120. 0 {src → tool}/compare.php
  121. +1 −1 tool/siteChecker.php
  122. +9 −3 tool/weaveControls.php
View
@@ -1,89 +1,54 @@
<?php
-use Danack\Console\Application;
-use Danack\Console\Output\BufferedOutput;
-use Danack\Console\Command\Command;
-use Danack\Console\Input\InputArgument;
-
-require __DIR__.'/../vendor/autoload.php';
-require __DIR__.'/../src/appFunctions.php';
-require __DIR__.'/../src/cliFunctions.php';
-
-register_shutdown_function('fatalErrorShutdownHandler');
-set_exception_handler('exceptionHandler');
-set_error_handler('errorHandler');
-
-//Figure out what Command was requested.
-try {
- $application = createApplication();
- $parsedCommand = $application->parseCommandLine();
-}
-catch (\Exception $e) {
- //@TODO change to just catch parseException when that's implemented
- $output = new BufferedOutput();
- $application->renderException($e, $output);
- echo $output->fetch();
- exit(-1);
-}
-
-$injector = new \Auryn\Injector();
-$injectionParams = require __DIR__."/../src/injectionParams.php";
-
-$injectionParams->addToInjector($injector);
+use Auryn\Injector;
+use Tier\TierCLIApp;
+use Tier\CLIFunction;
+ini_set('display_errors', 'on');
+
+require_once(__DIR__.'/../vendor/autoload.php');
+
+CLIFunction::setupErrorHandlers();
+
+// We're on the CLI - let errors be seen.
+// ini_set('display_errors', 'off');
+
+require_once __DIR__.'/../../clavis.php';
+
+$injector = new Injector();
+
+$standardInjectionParams = require __DIR__."/../src/injectionParams.php";
+/** @var $injectionParams \Tier\InjectionParams */
+$standardInjectionParams->addToInjector($injector);
+
+$cliInjectionParams = require __DIR__."/cliInjectionParams.php";
+
+
+// To make the example code be simple, they all assume the application's
+// current directory is the root of the project
chdir(realpath(__DIR__).'/../imagick');
-try {
- $input = $parsedCommand->getInput();
- foreach ($parsedCommand->getParams() as $key => $value) {
- $injector->defineParam($key, $value);
- }
- $injector->execute($parsedCommand->getCallable());
-}
-catch (Auryn\InjectionException $ie) {
- echo "Injection exception: ".$ie->getMessage()."\n";
- echo "Dependency chain is:\n";
- foreach ($ie->getDependencyChain() as $dependency) {
- echo " $dependency\n";
- }
-
- echo $ie->getTraceAsString();
-}
-catch (\Exception $e) {
- echo "Unexpected exception of type ".get_class($e)." running imagick-demos: ".$e->getMessage().PHP_EOL;
- echo $e->getTraceAsString();
- exit(-2);
-}
-
-/**
- * Creates a console application with all of the commands attached.
- * @return Application
- */
-function createApplication()
-{
- $statsCommand = new Command('statsRunner', 'Stats\SimpleStats::run');
- $statsCommand->setDescription("Run the stats collector and send the results to Librato.");
-
- $taskCommand = new Command('imageRunner', 'ImagickDemo\Queue\ImagickTaskRunner::run');
- $taskCommand->setDescription("Pull image request jobs off the queue and generated the images.");
-
- $clearCacheCommand = new Command('clearCache', 'ImagickDemo\Config\APCCacheEnvReader::clearCache');
- $clearCacheCommand->setDescription("Clear the apc cache.");
-
- $envWriteCommand = new Command('genEnvSettings', 'ImagickDemo\Config\EnvConfWriter::writeEnvFile');
- $envWriteCommand->setDescription("Write an env setting bash script.");
- $envWriteCommand->addArgument('env', InputArgument::REQUIRED, 'Which environment the settings should be generated for.');
- $envWriteCommand->addArgument('filename', InputArgument::REQUIRED, 'The file name that the env settings should be written to.');
-
- $clearRedisCommand = new Command('clearRedis', 'ImagickDemo\Queue\ImagickTaskQueue::clearStatusQueue');
- $clearRedisCommand->setDescription("Clear the imagick task queue.");
-
- $console = new Application("ImagickDemos", "1.0.0");
- $console->add($statsCommand);
- $console->add($taskCommand);
- $console->add($clearCacheCommand);
- $console->add($clearRedisCommand);
- $console->add($envWriteCommand);
-
- return $console;
-}
+/** @var $cliInjectionParams \Tier\InjectionParams */
+$cliInjectionParams->addToInjector($injector);
+
+$injector->alias('Danack\Console\Application', 'ImagickDemo\ConsoleApplication');
+
+$exceptionResolver = TierCLIApp::createStandardExceptionResolver();
+
+//$exceptionResolver->addExceptionHandler(
+// 'ServerContainer\UserErrorMessageException',
+// ['ServerContainer\App', 'handleUserErrorMessageException']
+//);
+//
+//$exceptionResolver->addExceptionHandler(
+// 'ServerContainer\ServerContainerException',
+// ['ServerContainer\App', 'handleServerContainerException']
+//);
+
+$tierApp = new TierCLIApp(
+ $injector,
+ $exceptionResolver
+);
+
+$tierApp->addInitialExecutable('Tier\Bridge\ConsoleRouter::routeCommand');
+$tierApp->execute();
@@ -0,0 +1,50 @@
+<?php
+
+use Tier\InjectionParams;
+
+// These classes will only be created by the injector once
+$shares = [
+ //'Amp\Reactor'
+];
+
+// Alias interfaces (or classes) to the actual types that should be used
+// where they are required.
+$aliases = [
+ //'ArtaxServiceBuilder\ResponseCache' => 'ArtaxServiceBuilder\ResponseCache\FileResponseCache',
+ 'Danack\Console\Application' => 'ImagickDemo\ConsoleApplication',
+];
+
+// Delegate the creation of types to callables.
+$delegates = [
+ //'ArtaxServiceBuilder\Oauth2Token' => 'ServerContainer\App::getOauthToken',
+ //'Amp\Reactor' => 'Amp\getReactor',
+ //'ServerContainer\Tool\EC2Manager' => 'ServerContainer\App::createEC2Manager',
+ //'ServerContainer\Tool\KillEC2TestInstances' => 'ServerContainer\App::createKillEC2TestInstances'
+];
+
+
+// If necessary, define some params that can be injected purely by name.
+$params = [
+// 'cacheDirectory' => realpath(__DIR__."/../var/cache"),
+// 'tempDirectory' => realpath(__DIR__."/../var/tmp"),
+// 'userAgent' => 'Danack/ServerContainer'
+];
+
+// If necessary, define some params per class.
+$defines = [
+];
+
+$prepares = [
+
+];
+
+$injectionParams = new InjectionParams(
+ $shares,
+ $aliases,
+ $delegates,
+ $params,
+ $prepares,
+ $defines
+);
+
+return $injectionParams;
View
@@ -15,7 +15,7 @@
"danack/jig": "^0.21.0",
"danack/scripthelper": "^0.0.3",
"danack/syntaxhighlighter": "~3.1.0",
- "danack/tier": "0.3.4",
+ "danack/tier": "dev-master",
"fluentdom/fluentdom": "v4.1.3",
"intahwebz/weaver": "~0.4.5",
"intahwebz/configurator": "^0.3.0",
View
@@ -4,7 +4,7 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "1914643d9a5949a4659f69ddde1c2b84",
+ "hash": "aedf5adec545a31a053decb2cf6371c7",
"packages": [
{
"name": "amphp/amp",
@@ -426,29 +426,30 @@
},
{
"name": "danack/tier",
- "version": "0.3.4",
+ "version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/Danack/Tier.git",
- "reference": "829398986d18c06d5deb85808004f6ae76f005d7"
+ "reference": "7952dcdf9394f8a414ca7563d111991015540e25"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/Danack/Tier/zipball/829398986d18c06d5deb85808004f6ae76f005d7",
- "reference": "829398986d18c06d5deb85808004f6ae76f005d7",
+ "url": "https://api.github.com/repos/Danack/Tier/zipball/7952dcdf9394f8a414ca7563d111991015540e25",
+ "reference": "7952dcdf9394f8a414ca7563d111991015540e25",
"shasum": ""
},
"require": {
- "rdlowrey/auryn": "^1.0.2",
+ "php": "^5.5 | ^7",
+ "rdlowrey/auryn": "^1.4.0",
"zendframework/zend-diactoros": "^1.3.2"
},
"require-dev": {
- "danack/jig": "^0.20.4",
+ "danack/jig": "^0.21.2",
"mockery/mockery": "0.9.1",
"nikic/fast-route": "0.3.0",
"phpunit/phpunit": "3.7.*",
"room11/caching": "^0.0.4",
- "room11/http": "^0.1.1",
+ "room11/http": "^0.2.0",
"squizlabs/php_codesniffer": "^2.0.0"
},
"type": "library",
@@ -468,14 +469,14 @@
"homepage": "http://www.basereality.com"
}
],
- "description": "An example of how to implement an application using DI with tiers",
+ "description": "An 'framework' application using DI with tiers for full 'Dependency inversion'.",
"keywords": [
"application",
"auryn",
"di",
"example"
],
- "time": "2016-01-31 17:01:29"
+ "time": "2016-04-22 10:20:05"
},
{
"name": "daverandom/libdns",
@@ -1093,16 +1094,16 @@
},
{
"name": "rdlowrey/auryn",
- "version": "v1.3.0",
+ "version": "v1.4.0",
"source": {
"type": "git",
"url": "https://github.com/rdlowrey/auryn.git",
- "reference": "2fdd89dfbbb9a98de7361981df6d802a9a38e0a5"
+ "reference": "2e4240791162dfe073d59654d8dc06df0eb0b73f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/rdlowrey/auryn/zipball/2fdd89dfbbb9a98de7361981df6d802a9a38e0a5",
- "reference": "2fdd89dfbbb9a98de7361981df6d802a9a38e0a5",
+ "url": "https://api.github.com/repos/rdlowrey/auryn/zipball/2e4240791162dfe073d59654d8dc06df0eb0b73f",
+ "reference": "2e4240791162dfe073d59654d8dc06df0eb0b73f",
"shasum": ""
},
"require": {
@@ -1150,7 +1151,7 @@
"dic",
"ioc"
],
- "time": "2016-03-07 22:58:51"
+ "time": "2016-03-14 20:10:19"
},
{
"name": "rdlowrey/nbsock",
@@ -1296,20 +1297,20 @@
},
{
"name": "zendframework/zend-diactoros",
- "version": "1.3.3",
+ "version": "1.3.5",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-diactoros.git",
- "reference": "4d54fde709664562eb63356f0250d527824d05de"
+ "reference": "b1d59735b672865dbeb930805029c24f226e3e77"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/4d54fde709664562eb63356f0250d527824d05de",
- "reference": "4d54fde709664562eb63356f0250d527824d05de",
+ "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/b1d59735b672865dbeb930805029c24f226e3e77",
+ "reference": "b1d59735b672865dbeb930805029c24f226e3e77",
"shasum": ""
},
"require": {
- "php": ">=5.4",
+ "php": "^5.4 || ^7.0",
"psr/http-message": "~1.0"
},
"provide": {
@@ -1342,7 +1343,7 @@
"psr",
"psr-7"
],
- "time": "2016-01-04 21:37:32"
+ "time": "2016-03-17 18:02:05"
},
{
"name": "zendframework/zend-escaper",
@@ -1430,19 +1431,20 @@
},
{
"name": "squizlabs/php_codesniffer",
- "version": "2.5.1",
+ "version": "2.6.0",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
- "reference": "6731851d6aaf1d0d6c58feff1065227b7fda3ba8"
+ "reference": "1bcdf03b068a530ac1962ce671dead356eeba43b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/6731851d6aaf1d0d6c58feff1065227b7fda3ba8",
- "reference": "6731851d6aaf1d0d6c58feff1065227b7fda3ba8",
+ "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1bcdf03b068a530ac1962ce671dead356eeba43b",
+ "reference": "1bcdf03b068a530ac1962ce671dead356eeba43b",
"shasum": ""
},
"require": {
+ "ext-simplexml": "*",
"ext-tokenizer": "*",
"ext-xmlwriter": "*",
"php": ">=5.1.2"
@@ -1503,7 +1505,7 @@
"phpcs",
"standards"
],
- "time": "2016-01-19 23:39:10"
+ "time": "2016-04-03 22:58:34"
}
],
"aliases": [
@@ -1516,7 +1518,8 @@
],
"minimum-stability": "stable",
"stability-flags": {
- "amphp/artax": 5
+ "amphp/artax": 5,
+ "danack/tier": 20
},
"prefer-stable": true,
"prefer-lowest": false,
Oops, something went wrong.

0 comments on commit 3313b42

Please sign in to comment.