programmatically / logo-wall
A library to scale different logos for display on a wall in a visually pleasing way
Installs: 46
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/programmatically/logo-wall
Requires
- php: ~8.1
- ext-imagick: *
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^13.0
README
programmatically/logo-wall is a small PHP library for measuring and normalizing logo dimensions
so logos render more consistently in a logo wall/grid. It is based on a React project called
LogoSoup by
Rostislav Melkumyan (Sanity Labs).
It can:
- Detect visible content bounds inside transparent/white-padded images
- Calculate a visual center and optional pixel density
- Produce normalized width/height values from measured logos
- Optionally return a cropped PNG data URI of content-only pixels
- Read raster logos plus SVG inputs
Requirements
- PHP
~8.1 ext-imagick
Installation
composer require programmatically/logo-wall
Usage
<?php use Programmatically\LogoWall\DTO\LogoSourceInput; use Programmatically\LogoWall\DTO\NormalizeOptions; use Programmatically\LogoWall\LogoWallNormalizer; $logos = [ new LogoSourceInput(__DIR__ . '/logos/acme.png', 'Acme'), new LogoSourceInput(__DIR__ . '/logos/bolt.webp', 'Bolt'), ]; $options = new NormalizeOptions( baseSize: 48, scaleFactor: 0.5, contrastThreshold: 10, densityAware: true, densityFactor: 0.5, cropToContent: true, ); $normalized = LogoWallNormalizer::normalizeLogos($logos, $options); foreach ($normalized as $logo) { printf( "%s => %dx%d\n", $logo->alt ?: basename($logo->src), $logo->normalizedWidth, $logo->normalizedHeight, ); // When cropToContent=true, this may contain a "data:image/png;base64,..." value. // $logo->croppedSrc }
NormalizeOptions Defaults
baseSize:48scaleFactor:0.5contrastThreshold:10densityAware:truedensityFactor:0.5cropToContent:false
Development
composer install vendor/bin/phpunit vendor/bin/phpstan analyse
Contributions
Contributions are welcome! Please submit issues and pull requests to the GitHub repository.