addequatte/photo-box-centering 问题修复 & 功能扩展

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

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

addequatte/photo-box-centering

最新稳定版本:v1.0

Composer 安装命令:

composer require addequatte/photo-box-centering

包简介

Allows you to center the photo on a given area, such as the coordinates of the face. You can specify the percentage of face filling in the final photo, which you can set yourself.

README 文档

README

Allows you to center the photo on a given area, such as the coordinates of the face. You can specify the percentage of face filling in the final photo, which you can set yourself.

Installation

composer require addequatte/photo-box-centering

For example

/**
 * public/index.php
 */
use Addequatte\PhotoBoxCentering\Data\PositionedBox;
use Addequatte\PhotoBoxCentering\Data\TranslatePlan;
use Addequatte\PhotoBoxCentering\Service\PhotoTranslator;

require_once __DIR__ . '/../vendor/autoload.php';

$photoUrl = 'data:image/png;base64, ' . base64_encode(file_get_contents(__DIR__ . '/pic.jpg'));
$photoWidth = 1280;
$photoHeight = 720;

$targetWidth = $_GET['w'] ?? 200;
$targetHeight = $_GET['h'] ?? 200;

$targetBoxPercent = $_GET['p'] ?? 40;

$translatePlan = new TranslatePlan($photoWidth, $photoHeight, $targetWidth, $targetHeight, $targetBoxPercent);

// Face coordinates on photo
$positionedBox = new PositionedBox(635, 100, 785, 315);

$photoTranslator = new PhotoTranslator();

$translatePhoto = $photoTranslator->center($translatePlan, $positionedBox);

$translateX = $translatePhoto->translateX();
$translateY = $translatePhoto->translateY();

$scale = $translatePhoto->scale();

include(__DIR__ . '/index.phtml');
<div class="photo_box" 
     style="overflow: hidden;
        width:{{ targetBoxWidth }}px;
        height:{{ targetBoxHeight }}px;" >
    <img 
            src="{{ photoUrl }}" 
            style="min-width:100%; 
            min-height:100%; 
            width:{{ scale }}%;
            transform:translate({{ translateX }}%, {{ translateY }}%)">
</div>

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固