From b7607e6fd740553403ca15aae56ad59a8becb47f Mon Sep 17 00:00:00 2001 From: AchillesKal Date: Mon, 8 Apr 2024 00:01:24 +0300 Subject: [PATCH] Add image compression --- .gitignore | 4 + Dockerfile | 1 + composer.json | 1 + composer.lock | 167 +++++++++++++++++++++++++++- config/bundles.php | 1 + config/packages/liip_imagine.yaml | 8 ++ config/routes/liip_imagine.yaml | 2 + symfony.lock | 13 +++ templates/blog_post/index.html.twig | 2 +- 9 files changed, 197 insertions(+), 2 deletions(-) create mode 100644 config/packages/liip_imagine.yaml create mode 100644 config/routes/liip_imagine.yaml diff --git a/.gitignore b/.gitignore index e750698..9a99d55 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,7 @@ /assets/styles/app.tailwind.css /public/uploads/ + +###> liip/imagine-bundle ### +/public/media/cache/ +###< liip/imagine-bundle ### diff --git a/Dockerfile b/Dockerfile index 6aeb0c7..6e84f18 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,6 +29,7 @@ RUN set -eux; \ intl \ opcache \ zip \ + gd \ ; # https://getcomposer.org/doc/03-cli.md#composer-allow-superuser diff --git a/composer.json b/composer.json index ba999e4..1813b00 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ "doctrine/doctrine-migrations-bundle": "^3.3", "doctrine/orm": "^3.1", "exercise/htmlpurifier-bundle": "^5.0", + "liip/imagine-bundle": "^2.12", "pagerfanta/doctrine-orm-adapter": "^4.3", "pagerfanta/twig": "^4.3", "runtime/frankenphp-symfony": "^0.2.0", diff --git a/composer.lock b/composer.lock index addc464..89d5d7f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4840edfa9253a38090fc964eabd869be", + "content-hash": "f0fdfba3ca7e2790519ec97344c365c1", "packages": [ { "name": "babdev/pagerfanta-bundle", @@ -2091,6 +2091,171 @@ ], "time": "2023-12-03T09:10:34+00:00" }, + { + "name": "imagine/imagine", + "version": "1.3.5", + "source": { + "type": "git", + "url": "https://github.com/php-imagine/Imagine.git", + "reference": "7151d553edec4dc2bbac60419f7a74ff34700e7f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-imagine/Imagine/zipball/7151d553edec4dc2bbac60419f7a74ff34700e7f", + "reference": "7151d553edec4dc2bbac60419f7a74ff34700e7f", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5 || ^8.4 || ^9.3" + }, + "suggest": { + "ext-exif": "to read EXIF metadata", + "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": "1.x-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" + ], + "support": { + "issues": "https://github.com/php-imagine/Imagine/issues", + "source": "https://github.com/php-imagine/Imagine/tree/1.3.5" + }, + "time": "2023-06-07T14:49:52+00:00" + }, + { + "name": "liip/imagine-bundle", + "version": "2.12.2", + "source": { + "type": "git", + "url": "https://github.com/liip/LiipImagineBundle.git", + "reference": "2ad259dd46ce55f93c6e8d87908d2572bd94796e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/liip/LiipImagineBundle/zipball/2ad259dd46ce55f93c6e8d87908d2572bd94796e", + "reference": "2ad259dd46ce55f93c6e8d87908d2572bd94796e", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "imagine/imagine": "^1.3.2", + "php": "^7.2|^8.0", + "symfony/filesystem": "^3.4|^4.4|^5.3|^6.0|^7.0", + "symfony/finder": "^3.4|^4.4|^5.3|^6.0|^7.0", + "symfony/framework-bundle": "^3.4.23|^4.4|^5.3|^6.0|^7.0", + "symfony/mime": "^4.4|^5.3|^6.0|^7.0", + "symfony/options-resolver": "^3.4|^4.4|^5.3|^6.0|^7.0", + "symfony/process": "^3.4|^4.4|^5.3|^6.0|^7.0", + "twig/twig": "^1.44|^2.9|^3.0" + }, + "require-dev": { + "amazonwebservices/aws-sdk-for-php": "^1.0", + "aws/aws-sdk-php": "^2.4|^3.0", + "doctrine/cache": "^1.11|^2.0", + "doctrine/persistence": "^1.3|^2.0", + "enqueue/enqueue-bundle": "^0.9|^0.10", + "ext-gd": "*", + "league/flysystem": "^1.0|^2.0|^3.0", + "phpstan/phpstan": "^1.10.0", + "psr/cache": "^1.0|^2.0|^3.0", + "psr/log": "^1.0", + "symfony/browser-kit": "^3.4|^4.4|^5.3|^6.0|^7.0", + "symfony/cache": "^3.4|^4.4|^5.3|^6.0|^7.0", + "symfony/console": "^3.4|^4.4|^5.3|^6.0|^7.0", + "symfony/dependency-injection": "^3.4|^4.4|^5.3|^6.0|^7.0", + "symfony/form": "^3.4|^4.4|^5.3|^6.0|^7.0", + "symfony/messenger": "^4.4|^5.3|^6.0|^7.0", + "symfony/phpunit-bridge": "^7.0.2", + "symfony/templating": "^3.4|^4.4|^5.3|^6.0", + "symfony/validator": "^3.4|^4.4|^5.3|^6.0|^7.0", + "symfony/yaml": "^3.4|^4.4|^5.3|^6.0|^7.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", + "rokka/imagine-vips": "required to use 'vips' driver", + "symfony/messenger": "If you like to process images in background", + "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": "https://www.liip.ch", + "keywords": [ + "bundle", + "image", + "imagine", + "liip", + "manipulation", + "photos", + "pictures", + "symfony", + "transformation" + ], + "support": { + "issues": "https://github.com/liip/LiipImagineBundle/issues", + "source": "https://github.com/liip/LiipImagineBundle/tree/2.12.2" + }, + "time": "2024-02-23T21:12:25+00:00" + }, { "name": "monolog/monolog", "version": "3.5.0", diff --git a/config/bundles.php b/config/bundles.php index 8443b45..c90df5a 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -20,4 +20,5 @@ Symfonycasts\TailwindBundle\SymfonycastsTailwindBundle::class => ['all' => true], Symfony\UX\Autocomplete\AutocompleteBundle::class => ['all' => true], Exercise\HTMLPurifierBundle\ExerciseHTMLPurifierBundle::class => ['all' => true], + Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true], ]; diff --git a/config/packages/liip_imagine.yaml b/config/packages/liip_imagine.yaml new file mode 100644 index 0000000..eea4331 --- /dev/null +++ b/config/packages/liip_imagine.yaml @@ -0,0 +1,8 @@ +# Documentation on how to configure the bundle can be found at: https://symfony.com/doc/current/bundles/LiipImagineBundle/basic-usage.html +liip_imagine: + # valid drivers options include "gd" or "gmagick" or "imagick" + driver: "gd" + + filter_sets: + blog_list: + quality: 75 diff --git a/config/routes/liip_imagine.yaml b/config/routes/liip_imagine.yaml new file mode 100644 index 0000000..201cbd5 --- /dev/null +++ b/config/routes/liip_imagine.yaml @@ -0,0 +1,2 @@ +_liip_imagine: + resource: "@LiipImagineBundle/Resources/config/routing.yaml" diff --git a/symfony.lock b/symfony.lock index f3f82eb..8fb6d6f 100644 --- a/symfony.lock +++ b/symfony.lock @@ -62,6 +62,19 @@ "config/packages/exercise_html_purifier.yaml" ] }, + "liip/imagine-bundle": { + "version": "2.12", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "main", + "version": "1.8", + "ref": "d1227d002b70d1a1f941d91845fcd7ac7fbfc929" + }, + "files": [ + "config/packages/liip_imagine.yaml", + "config/routes/liip_imagine.yaml" + ] + }, "phpunit/phpunit": { "version": "9.6", "recipe": { diff --git a/templates/blog_post/index.html.twig b/templates/blog_post/index.html.twig index 71933bb..c779e6d 100644 --- a/templates/blog_post/index.html.twig +++ b/templates/blog_post/index.html.twig @@ -22,7 +22,7 @@
{# Check if the blog post has a banner image #} {% if blog_post.banner %} - {{ blog_post.title }} + {{ blog_post.title }} {% else %}