swatty007/faker-image-generator 问题修复 & 功能扩展

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

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

swatty007/faker-image-generator

Composer 安装命令:

composer require swatty007/faker-image-generator

包简介

Placeholder Image Generator for FakerPHP

README 文档

README

Package Banner

Latest Version on Packagist License: MIT Build Status Code Style Quality Score Total Downloads

Generator of placeholder-type images using GD for fzaninotto/Faker to quickly generate fake images within your application or tests, without the need to rely on external services.

This is a fork from bruceheller/images-generator as that package seems to not be actively maintained anymore.

Installation

You can install the package via composer:

composer require swatty007/faker-image-generator

Configuration

After installing the package you can publish the configuration file via:

php artisan vendor:publish --provider="Swatty007\FakerImageGenerator\FakerImageGeneratorServiceProvider"

It contains some optional configuration parameters and is fully documented.

The configuration allows you to define some global image properties which will be shared across all Generator Instances. This is an addition to the original package to make is easier to share a similar style throughout your application.

Usage

Use the FakerImageGenerationProvider class in combination with Faker to produce new images:

$faker = Factory::create();
$imageGenerator = new FakerImageGenerationProvider($faker);
$image = $faker->imageGenerator();

It will generate a black png picture of 640*480 pixels inside your temp directory (if available) and return the full path of the picture like this: '/tmp/13b73edae8443990be1aa8f1a483bc27.png'.

Parameters

The imageGenerator() method allows you to define rendering options on a per element basis, those options are identical to your configuration properties and will allow you quickly generate unique images.

Examples:

$faker->imageGenerator();

Will generate a 640x480 black png picture with the text '640x480' in white.

Default Image

$faker->imageGenerator('img', 640, 480, 'png', true, 'Faker', '#0018ff', '#ffd800');

Will generate a 640x480 blue png picture with the text 'Faker' in yellow inside an img directory of your project and return the full path such as 'img/f523f8bec6ed65fb1d63ae8d09850f9c.png' like this:

Custom Image

More complex example using the power of Faker:

$faker->imageGenerator('img', $faker->numberBetween(600, 800), $faker->numberBetween(400, 600), 'jpg', true, $faker->word, $faker->hexColor, $faker->hexColor);

Will return a jpeg of a random color picture with a width between 600 and 800 pixels, height between 400 and 600 pixels, with a random word written in a random color!

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

TODO

As this is mainly a fork of the existing package, to get it running within modern applications, its future development plans could apply to this package as well. However, its current functionality fulfills my needs. Nonetheless, some TODOs remain & are open for pull requests 🧐

  • Improve Readme
  • Transition to GitHub Actions
  • Improve & Extend existing tests!
  • Add support for ImageMagick and/or GraphicsMagick for faster generation of pictures.

Otherwise, any suggestion is welcome! You can fork this project and submit your PR :)

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email info@martin-niehoff.de instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

The Roboto font file included in this project is under Apache Licence 2.0 as mentioned on the Roboto repository.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-02-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固