programmatically/logo-wall 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

programmatically/logo-wall

最新稳定版本:1.0.0

Composer 安装命令:

composer require programmatically/logo-wall

包简介

A library to scale different logos for display on a wall in a visually pleasing way

README 文档

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: 48
  • scaleFactor: 0.5
  • contrastThreshold: 10
  • densityAware: true
  • densityFactor: 0.5
  • cropToContent: 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.

统计信息

  • 总下载量: 52
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-09