Skip to content

Commit

Permalink
Update Favicons functionality and configuration options (#199)
Browse files Browse the repository at this point in the history
* Update Favicons functionality and configuration options

The code updates include the addition of "use_silhouette" and "potrace" settings in "Favicons.php", changes to "FaviconsCompiler.php" to support new silhouette generation functionality for Safari pinned tabs, and a background color setting for ImagickImageProcessor. Code has also been modified to remove hash references in icon URL placements. The PHPStan baseline has been updated due to the code changes.
  • Loading branch information
Spomky authored May 12, 2024
1 parent 828d87a commit 1328149
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 68 deletions.
15 changes: 0 additions & 15 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -580,21 +580,6 @@ parameters:
count: 2
path: src/Service/FaviconsCompiler.php

-
message: "#^Parameter \\#1 \\$asset of method SpomkyLabs\\\\PwaBundle\\\\Service\\\\FaviconsCompiler\\:\\:processBrowserConfig\\(\\) expects SpomkyLabs\\\\PwaBundle\\\\Service\\\\MappedAsset, string given\\.$#"
count: 1
path: src/Service/FaviconsCompiler.php

-
message: "#^Parameter \\#1 \\$content of method SpomkyLabs\\\\PwaBundle\\\\Service\\\\FaviconsCompiler\\:\\:processIcon\\(\\) expects string, SpomkyLabs\\\\PwaBundle\\\\Service\\\\MappedAsset given\\.$#"
count: 5
path: src/Service/FaviconsCompiler.php

-
message: "#^Parameter \\$asset of method SpomkyLabs\\\\PwaBundle\\\\Service\\\\FaviconsCompiler\\:\\:processBrowserConfig\\(\\) has invalid type SpomkyLabs\\\\PwaBundle\\\\Service\\\\MappedAsset\\.$#"
count: 1
path: src/Service/FaviconsCompiler.php

-
message: "#^Strict comparison using \\!\\=\\= between string and null will always evaluate to true\\.$#"
count: 1
Expand Down
6 changes: 4 additions & 2 deletions src/Dto/Favicons.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ final class Favicons
#[SerializedName('low_resolution')]
public null|bool $lowResolution = null;

#[SerializedName('only_tile_silhouette')]
public null|bool $onlyTileSilhouette = null;
#[SerializedName('use_silhouette')]
public null|bool $useSilhouette = null;

public null|string $potrace = null;
}
1 change: 1 addition & 0 deletions src/ImageProcessor/ImagickImageProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function getSizes(string $image): array
private function createMainImage(string $image, Configuration $configuration): Imagick
{
$mainImage = new Imagick();
$mainImage->setBackgroundColor(new ImagickPixel('transparent'));
$mainImage->readImageBlob($image);
$mainImage->setImageBackgroundColor(new ImagickPixel('transparent'));

Expand Down
18 changes: 10 additions & 8 deletions src/Resources/config/definition/favicons.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
->end()
->scalarNode('safari_pinned_tab_color')
->defaultNull()
->info('The color of the Safari pinned tab.')
->info('The color of the Safari pinned tab. Requires "use_silhouette" to be set to "true".')
->example(['red', '#f5ef06'])
->end()
->scalarNode('tile_color')
Expand All @@ -43,17 +43,19 @@
->max(100)
->info('The scale of the icon.')
->end()
->booleanNode('generate_precomposed')
->defaultFalse()
->info('Generate precomposed icons. Useful for old iOS devices.')
->end()
->booleanNode('low_resolution')
->defaultFalse()
->info('Include low resolution icons.')
->end()
->booleanNode('only_tile_silhouette')
->defaultTrue()
->info('Only tile silhouette for Windows 8+.')
->booleanNode('use_silhouette')
->defaultNull()
->info(
'Use only the silhouette of the icon. Applicable for macOS Safari and Windows 8+. Requires potrace to be installed.'
)
->end()
->scalarNode('potrace')
->defaultValue('potrace')
->info('The path to the potrace binary.')
->end()
->end()
->end()
Expand Down
Loading

0 comments on commit 1328149

Please sign in to comment.