Browse Source

[partial] implementing liip imagine and autoresize on upload subscriber

master
art.dambrine 4 years ago
parent
commit
8c65caa72e
  1. 4
      .gitignore
  2. 4
      .idea/php.xml
  3. 1
      composer.json
  4. 152
      composer.lock
  5. 1
      config/bundles.php
  6. 4
      config/packages/liip_imagine.yaml
  7. 2
      config/routes/liip_imagine.yaml
  8. 2
      config/services.yaml
  9. 6714
      public/js/bootstrap.bundle.js
  10. 1
      public/js/bootstrap.bundle.js.map
  11. 3
      public/js/bootstrap.bundle.js.map:Zone.Identifier
  12. 3
      public/js/bootstrap.bundle.js:Zone.Identifier
  13. 7
      public/js/bootstrap.bundle.min.js
  14. 1
      public/js/bootstrap.bundle.min.js.map
  15. 3
      public/js/bootstrap.bundle.min.js.map:Zone.Identifier
  16. 3
      public/js/bootstrap.bundle.min.js:Zone.Identifier
  17. 4944
      public/js/bootstrap.esm.js
  18. 1
      public/js/bootstrap.esm.js.map
  19. 3
      public/js/bootstrap.esm.js.map:Zone.Identifier
  20. 3
      public/js/bootstrap.esm.js:Zone.Identifier
  21. 7
      public/js/bootstrap.esm.min.js
  22. 1
      public/js/bootstrap.esm.min.js.map
  23. 3
      public/js/bootstrap.esm.min.js.map:Zone.Identifier
  24. 3
      public/js/bootstrap.esm.min.js:Zone.Identifier
  25. 3
      public/js/bootstrap.js.map:Zone.Identifier
  26. 3
      public/js/bootstrap.js:Zone.Identifier
  27. 3
      public/js/bootstrap.min.js.map:Zone.Identifier
  28. 3
      public/js/bootstrap.min.js:Zone.Identifier
  29. 46
      src/Event/ResizeImageOnUploadSubscriber.php
  30. 16
      symfony.lock

4
.gitignore

@ -15,3 +15,7 @@
.phpunit.result.cache .phpunit.result.cache
/phpunit.xml /phpunit.xml
###< symfony/phpunit-bridge ### ###< symfony/phpunit-bridge ###
###> liip/imagine-bundle ###
/public/media/cache/
###< liip/imagine-bundle ###

4
.idea/php.xml

@ -109,6 +109,10 @@
<path value="$PROJECT_DIR$/vendor/api-platform/core" /> <path value="$PROJECT_DIR$/vendor/api-platform/core" />
<path value="$PROJECT_DIR$/vendor/knplabs/knp-paginator-bundle" /> <path value="$PROJECT_DIR$/vendor/knplabs/knp-paginator-bundle" />
<path value="$PROJECT_DIR$/vendor/knplabs/knp-components" /> <path value="$PROJECT_DIR$/vendor/knplabs/knp-components" />
<path value="$PROJECT_DIR$/vendor/vich/uploader-bundle" />
<path value="$PROJECT_DIR$/vendor/jms/metadata" />
<path value="$PROJECT_DIR$/vendor/imagine/imagine" />
<path value="$PROJECT_DIR$/vendor/liip/imagine-bundle" />
</include_path> </include_path>
</component> </component>
<component name="PhpProjectSharedConfiguration" php_language_level="7.2"> <component name="PhpProjectSharedConfiguration" php_language_level="7.2">

1
composer.json

@ -14,6 +14,7 @@
"doctrine/doctrine-migrations-bundle": "^3.0", "doctrine/doctrine-migrations-bundle": "^3.0",
"doctrine/orm": "^2.8", "doctrine/orm": "^2.8",
"knplabs/knp-paginator-bundle": "^5.4", "knplabs/knp-paginator-bundle": "^5.4",
"liip/imagine-bundle": "^2.6",
"nelmio/cors-bundle": "^2.1", "nelmio/cors-bundle": "^2.1",
"phpdocumentor/reflection-docblock": "^5.2", "phpdocumentor/reflection-docblock": "^5.2",
"sensio/framework-extra-bundle": "^5.1", "sensio/framework-extra-bundle": "^5.1",

152
composer.lock

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "4193f9739f8bbbcc296b1562066343b1", "content-hash": "c740d20ff0f08bb32594a2e6b0c4e69d",
"packages": [ "packages": [
{ {
"name": "api-platform/core", "name": "api-platform/core",
@ -1683,6 +1683,64 @@
], ],
"time": "2021-01-14T21:52:44+00:00" "time": "2021-01-14T21:52:44+00:00"
}, },
{
"name": "imagine/imagine",
"version": "1.2.4",
"source": {
"type": "git",
"url": "https://github.com/avalanche123/Imagine.git",
"reference": "d2e18be6e930ca169e4f921ef73ebfc061bf55d8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/avalanche123/Imagine/zipball/d2e18be6e930ca169e4f921ef73ebfc061bf55d8",
"reference": "d2e18be6e930ca169e4f921ef73ebfc061bf55d8",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.2",
"phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5 || ^8.4 || ^9.3"
},
"suggest": {
"ext-gd": "to use the GD implementation",
"ext-gmagick": "to use the Gmagick implementation",
"ext-imagick": "to use the Imagick implementation"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-develop": "0.7-dev"
}
},
"autoload": {
"psr-4": {
"Imagine\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bulat Shakirzyanov",
"email": "mallluhuct@gmail.com",
"homepage": "http://avalanche123.com"
}
],
"description": "Image processing for PHP 5.3",
"homepage": "http://imagine.readthedocs.org/",
"keywords": [
"drawing",
"graphics",
"image manipulation",
"image processing"
],
"time": "2020-11-03T22:35:03+00:00"
},
{ {
"name": "jms/metadata", "name": "jms/metadata",
"version": "2.5.0", "version": "2.5.0",
@ -2065,6 +2123,98 @@
], ],
"time": "2021-02-25T21:54:58+00:00" "time": "2021-02-25T21:54:58+00:00"
}, },
{
"name": "liip/imagine-bundle",
"version": "2.6.0",
"source": {
"type": "git",
"url": "https://github.com/liip/LiipImagineBundle.git",
"reference": "afa4193c7fde027426ebb19e73878cd026438bbd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/liip/LiipImagineBundle/zipball/afa4193c7fde027426ebb19e73878cd026438bbd",
"reference": "afa4193c7fde027426ebb19e73878cd026438bbd",
"shasum": ""
},
"require": {
"imagine/imagine": "^1.2.4",
"php": "^7.1|^8.0",
"symfony/filesystem": "^3.4|^4.3|^5.0",
"symfony/finder": "^3.4|^4.3|^5.0",
"symfony/framework-bundle": "^3.4.23|^4.3|^5.0",
"symfony/mime": "^4.3|^5.0",
"symfony/options-resolver": "^3.4|^4.3|^5.0",
"symfony/process": "^3.4|^4.3|^5.0",
"twig/twig": "^1.44|^2.9|^3.0"
},
"require-dev": {
"amazonwebservices/aws-sdk-for-php": "^1.0",
"aws/aws-sdk-php": "^2.4",
"doctrine/cache": "^1.1",
"doctrine/persistence": "^1.3|^2.0",
"enqueue/enqueue-bundle": "^0.9|^0.10",
"ext-gd": "*",
"league/flysystem": "^1.0|^2.0",
"psr/log": "^1.0",
"symfony/browser-kit": "^3.4|^4.3|^5.0",
"symfony/console": "^3.4|^4.3|^5.0",
"symfony/dependency-injection": "^3.4|^4.3|^5.0",
"symfony/form": "^3.4|^4.3|^5.0",
"symfony/phpunit-bridge": "^5.2",
"symfony/templating": "^3.4|^4.3|^5.0",
"symfony/validator": "^3.4|^4.3|^5.0",
"symfony/yaml": "^3.4|^4.3|^5.0"
},
"suggest": {
"alcaeus/mongo-php-adapter": "required for mongodb components",
"amazonwebservices/aws-sdk-for-php": "required to use AWS version 1 cache resolver",
"aws/aws-sdk-php": "required to use AWS version 2/3 cache resolver",
"doctrine/mongodb-odm": "required to use mongodb-backed doctrine components",
"enqueue/enqueue-bundle": "^0.9 add if you like to process images in background",
"ext-exif": "required to read EXIF metadata from images",
"ext-gd": "required to use gd driver",
"ext-gmagick": "required to use gmagick driver",
"ext-imagick": "required to use imagick driver",
"ext-mongodb": "required for mongodb components",
"league/flysystem": "required to use FlySystem data loader or cache resolver",
"monolog/monolog": "A psr/log compatible logger is required to enable logging",
"symfony/templating": "required to use deprecated Templating component instead of Twig"
},
"type": "symfony-bundle",
"autoload": {
"psr-4": {
"Liip\\ImagineBundle\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Liip and other contributors",
"homepage": "https://github.com/liip/LiipImagineBundle/contributors"
}
],
"description": "This bundle provides an image manipulation abstraction toolkit for Symfony-based projects.",
"homepage": "http://liip.ch",
"keywords": [
"bundle",
"image",
"imagine",
"liip",
"manipulation",
"photos",
"pictures",
"symfony",
"transformation"
],
"time": "2021-03-31T06:42:04+00:00"
},
{ {
"name": "monolog/monolog", "name": "monolog/monolog",
"version": "2.2.0", "version": "2.2.0",

1
config/bundles.php

@ -16,4 +16,5 @@ return [
ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
Knp\Bundle\PaginatorBundle\KnpPaginatorBundle::class => ['all' => true], Knp\Bundle\PaginatorBundle\KnpPaginatorBundle::class => ['all' => true],
Vich\UploaderBundle\VichUploaderBundle::class => ['all' => true], Vich\UploaderBundle\VichUploaderBundle::class => ['all' => true],
Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true],
]; ];

4
config/packages/liip_imagine.yaml

@ -0,0 +1,4 @@
# See dos how to configure the bundle: https://symfony.com/doc/current/bundles/LiipImagineBundle/basic-usage.html
liip_imagine:
# valid drivers options include "gd" or "gmagick" or "imagick"
driver: "gd"

2
config/routes/liip_imagine.yaml

@ -0,0 +1,2 @@
_liip_imagine:
resource: "@LiipImagineBundle/Resources/config/routing.yaml"

2
config/services.yaml

@ -29,3 +29,5 @@ services:
# add more service definitions when explicit configuration is needed # add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones # please note that last definitions always *replace* previous ones
Liip\ImagineBundle\Service\FilterService:
alias: 'liip_imagine.service.filter'

6714
public/js/bootstrap.bundle.js

File diff suppressed because it is too large

1
public/js/bootstrap.bundle.js.map

File diff suppressed because one or more lines are too long

3
public/js/bootstrap.bundle.js.map:Zone.Identifier

@ -1,3 +0,0 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\a.dambrine\Downloads\bootstrap-5.0.0-beta3-dist.zip

3
public/js/bootstrap.bundle.js:Zone.Identifier

@ -1,3 +0,0 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\a.dambrine\Downloads\bootstrap-5.0.0-beta3-dist.zip

7
public/js/bootstrap.bundle.min.js

File diff suppressed because one or more lines are too long

1
public/js/bootstrap.bundle.min.js.map

File diff suppressed because one or more lines are too long

3
public/js/bootstrap.bundle.min.js.map:Zone.Identifier

@ -1,3 +0,0 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\a.dambrine\Downloads\bootstrap-5.0.0-beta3-dist.zip

3
public/js/bootstrap.bundle.min.js:Zone.Identifier

@ -1,3 +0,0 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\a.dambrine\Downloads\bootstrap-5.0.0-beta3-dist.zip

4944
public/js/bootstrap.esm.js

File diff suppressed because it is too large

1
public/js/bootstrap.esm.js.map

File diff suppressed because one or more lines are too long

3
public/js/bootstrap.esm.js.map:Zone.Identifier

@ -1,3 +0,0 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\a.dambrine\Downloads\bootstrap-5.0.0-beta3-dist.zip

3
public/js/bootstrap.esm.js:Zone.Identifier

@ -1,3 +0,0 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\a.dambrine\Downloads\bootstrap-5.0.0-beta3-dist.zip

7
public/js/bootstrap.esm.min.js

File diff suppressed because one or more lines are too long

1
public/js/bootstrap.esm.min.js.map

File diff suppressed because one or more lines are too long

3
public/js/bootstrap.esm.min.js.map:Zone.Identifier

@ -1,3 +0,0 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\a.dambrine\Downloads\bootstrap-5.0.0-beta3-dist.zip

3
public/js/bootstrap.esm.min.js:Zone.Identifier

@ -1,3 +0,0 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\a.dambrine\Downloads\bootstrap-5.0.0-beta3-dist.zip

3
public/js/bootstrap.js.map:Zone.Identifier

@ -1,3 +0,0 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\a.dambrine\Downloads\bootstrap-5.0.0-beta3-dist.zip

3
public/js/bootstrap.js:Zone.Identifier

@ -1,3 +0,0 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\a.dambrine\Downloads\bootstrap-5.0.0-beta3-dist.zip

3
public/js/bootstrap.min.js.map:Zone.Identifier

@ -1,3 +0,0 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\a.dambrine\Downloads\bootstrap-5.0.0-beta3-dist.zip

3
public/js/bootstrap.min.js:Zone.Identifier

@ -1,3 +0,0 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\a.dambrine\Downloads\bootstrap-5.0.0-beta3-dist.zip

46
src/Event/ResizeImageOnUploadSubscriber.php

@ -0,0 +1,46 @@
<?php
namespace App\Event;
use App\Entity\Pokemon;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Vich\UploaderBundle\Event\Event;
use Vich\UploaderBundle\Event\Events;
use Liip\ImagineBundle\Service\FilterService;
class ResizeImageOnUploadSubscriber implements EventSubscriberInterface
{
/**
* @var FilterService
*/
private $filterService;
public function __construct(FilterService $filterService)
{
$this->filterService = $filterService;
}
public static function getSubscribedEvents(): array
{
return [
Events::POST_UPLOAD => 'onPostUpload',
];
}
public function onPostUpload(Event $event): void
{
$object = $event->getObject();
if ($object instanceof Pokemon && $object->getImageFile()) {
// TODO : https://github.com/dustin10/VichUploaderBundle/issues/119
// TODO : install GD
//$thumbnailPath = $this->filterService->getUrlOfFilteredImage($object->getImagePath(), 'some_imagine_filter');
// maybe do something with `$thumbnailPath`...
}
}
}

16
symfony.lock

@ -105,6 +105,9 @@
"friendsofphp/proxy-manager-lts": { "friendsofphp/proxy-manager-lts": {
"version": "v1.0.3" "version": "v1.0.3"
}, },
"imagine/imagine": {
"version": "1.2.4"
},
"jms/metadata": { "jms/metadata": {
"version": "2.5.0" "version": "2.5.0"
}, },
@ -123,6 +126,19 @@
"laminas/laminas-zendframework-bridge": { "laminas/laminas-zendframework-bridge": {
"version": "1.2.0" "version": "1.2.0"
}, },
"liip/imagine-bundle": {
"version": "1.8",
"recipe": {
"repo": "github.com/symfony/recipes-contrib",
"branch": "master",
"version": "1.8",
"ref": "5a5bdc2d0e2533ed6935d5ae562f2b318a8fc1ee"
},
"files": [
"config/packages/liip_imagine.yaml",
"config/routes/liip_imagine.yaml"
]
},
"monolog/monolog": { "monolog/monolog": {
"version": "2.2.0" "version": "2.2.0"
}, },

Loading…
Cancel
Save