定制 dmdnkv/faker-someimage-providers 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

dmdnkv/faker-someimage-providers

Composer 安装命令:

composer require dmdnkv/faker-someimage-providers

包简介

Fake image providers for Faker PHP library (fzaninotto/Faker). Implemented providers: LoremFlickr (http://loremflickr.com), DummyImage (http://dummyimage.com)

README 文档

README

Fake images provider for Faker PHP library.

There are several image providers implemented:

Installation

composer require dmdnkv/faker-someimage-provider

Basic Usage

LoremFlickr


use Dmdnkv\Faker\Provider\LoremFlickr;

/**
 * Add LoremFlickr provider to faker generator
 */

$faker = new Faker\Generator();
$faker->addProvider(new LoremFlickr($faker));

/**
 * Get url to random picture matching the keywords brazil or rio, of 320 x 240 pixels.
 */

$imageUrl = $faker->someImageUrl(
    320,
    240,
    [
        LoremFlickr::OPTION_KEYWORDS => ['brazil', 'rio']
    ]
);

/**
 * Get url to random picture matching the keywords paris and girl, of 320 x 240 pixels.
 */

$imageUrl = $faker->someImageUrl(
    320,
    240,
    [
        LoremFlickr::OPTION_KEYWORDS => ['paris', 'girl'],
        LoremFlickr::OPTION_LOGIC => LoremFlickr::KEYWORDS_LOGIC_AND,
    ]
);

/**
 * Get url to random picture matching the keywords brazil or rio, of 320 x 240 pixels.
 * There is color filter applied to image (available filters: gray, red, green, blue).
 */

$imageUrl = $faker->someImageUrl(
    320,
    240,
    [
        LoremFlickr::OPTION_KEYWORDS => ['brazil', 'rio'],
        LoremFlickr::OPTION_FILTER => LoremFlickr::FILTER_GRAY,
    ]
);

/**
 * Download random picture matching the keywords brazil or rio, of 320 x 240 pixels.
 * Save picture to system temp folder and return filename only.
 */
 
$fileName = $this->faker->someImage(
    320,
    240,
    [
        LoremFlickr::OPTION_KEYWORDS => ['brazil', 'rio'],
        LoremFlickr::OPTION_DIR => sys_get_temp_dir(),
        LoremFlickr::OPTION_FULL_PATH => false
    ]
);

DummyImage


use Dmdnkv\Faker\Provider\DummyImage;

/**
 * Add DummyImage provider to faker generator
 */

$faker = new Faker\Generator();
$faker->addProvider(new DummyImage($faker));

/**
 * Get url to PNG picture with black background color and white text `some text here`
 */
$imageUrl = $faker->someImageUrl(
    320,
    240,
    [
        DummyImage::OPTION_BG_COLOR => '000000',
        DummyImage::OPTION_FG_COLOR => 'ffffff',
        DummyImage::OPTION_TEXT => 'some text here',
        DummyImage::OPTION_EXTENSION => DummyImage::EXTENSION_PNG,
    ]
);

/**
 * Download PNG picture with black background color and white text `some text here`.
 * Save picture to system temp folder and return filename only.
 */ 
$fileName = $faker->someImageUrl(
    320,
    240,
    [
        DummyImage::OPTION_BG_COLOR => '000000',
        DummyImage::OPTION_FG_COLOR => 'ffffff',
        DummyImage::OPTION_TEXT => 'some text here',
        DummyImage::OPTION_EXTENSION => DummyImage::EXTENSION_PNG,
        DummyImage::OPTION_DIR => sys_get_temp_dir(),
        DummyImage::OPTION_FULL_PATH => false,        
    ]
);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-06-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固