Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Twig Filter to get the average color of an Image. Used in Email… #127

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

Coffeemaker
Copy link
Contributor

Added Twig Filter to get the average color of an Image. Used in Email as bg-color

@Coffeemaker Coffeemaker requested a review from Ovascos August 19, 2024 19:07
src/Twig/AverageColorFromImageFilterExtension.php Outdated Show resolved Hide resolved
return sprintf("#%02x%02x%02x", $rgb["red"], $rgb["green"], $rgb["blue"]);
}

private function createImageFromFile(string $imagePath): \GdImage|false {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use statement for GdImage
maybe use null instead of false for "no image"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false is returned from imagecreatefrom*** if an error happened. So false to be complient with that.

@@ -1,7 +1,7 @@
{# TODO embedd logo to make it independent of changes #}
<div class="head-wrap bg-primary"
{% if settings.get('style.bg_image') is not empty %}
style="background-image: url({{ absolute_url(settings.get('style.bg_image')) }})"
style="background-image: url({{ absolute_url(settings.get('style.bg_image')) }}); background-color: {{ absolute_url(settings.get('style.bg_image')) | average_color }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no absolute_url here, as this is the parameter for average_color. Use the file path instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants