承接 freshleafmedia/autofocus 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

freshleafmedia/autofocus

最新稳定版本:1.0.2

Composer 安装命令:

composer require freshleafmedia/autofocus

包简介

Automatic image focal point detection

README 文档

README

Automatic image focal point detection.

Overview

Autofocus is an image analysis library which attempts to determine where the focal point of an image is.

Installation

composer require freshleafmedia/autofocus 

Usage

use FreshleafMedia\Autofocus\FocalPointDetector; $focalPointDetector = new FocalPointDetector(); $point = $focalPointDetector->getPoint(new Imagick('/path/to/image')); $point->x; // 283 $point->y; // 157

How it works

The algorithm works by picking the busiest area of the image:

  1. Detect edges
  2. Apply a vignette. This pushes the focus towards the centre
  3. Split the image into segments
  4. Calculate the average brightness within each segment
  5. Pick the segment with the highest brightness

Options

The FocalPointDetector constructor takes a number of options:

new FocalPointDetector( segmentSize: 20, // The size of the Segments in pixels );

Debugging

You can get access to the processed image to see how the focus was determined:

use FreshleafMedia\Autofocus\FocalPointDetector; $focalPointDetector = new FocalPointDetector(); $focalPointDetector ->debug(new Imagick('/path/to/image')) ->drawHeatMap() ->drawGrid() ->getRawImage() ->writeImage(__DIR__ . '/debug.jpg');

Tests

Unit tests can be run via composer test

Credits

This library is essentially a PHP port of https://github.com/sylvainjule/kirby-autofocus.

License

See LICENSE

统计信息

  • 总下载量: 5.98k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 3
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固