boomdraw/laravel-dummy-image 问题修复 & 功能扩展

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

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

boomdraw/laravel-dummy-image

Composer 安装命令:

composer require boomdraw/laravel-dummy-image

包简介

Laravel dummy image generator based on kingkool68/dummyimage

README 文档

README

This package allows you to generate dynamic dummy image in Laravel framework.

It's based on the Russell Heimlich's dummy image generator

Once installed you can do stuff like this:

// Generate and store an image
DummyImage::put($path, $disk);

// Generate and return image as response
DummyImage::toResponse($code, $headers);

// Generate and return image as base64
DummyImage::toBase64($code, $headers);

Installation

Laravel

You can install the package via composer:

composer require boomdraw/laravel-dummy-image

You can publish the config file with:

php artisan vendor:publish --provider="BoomDraw\DummyImage\DummyImageServiceProvider" --tag="config"

When published, the config/dummyimage.php config file contains:

return [

    /*
     * Default disk for generated image
     */
    'disk' => 'local',

    /*
     * Default path for generated image
     */
    'path' => 'dummyimage',

    /*
     * Additional headers for response
     */
    'headers' => [
        //
    ],

    /*
     * Additional html color names with hex value for name to hex convertation
     */
    'color_names' => [
        //'color_name' => '00ffff'
    ],
];

Usage

// Generate an image with custom params
$image = DummyImage::generate($dimensions = '200x1:5', $format = 'gif', $bg_color = 'ff00cc', $fg_color = '00ffcc', $text = 'I am image text');

// Generate and store an image
$image->put($path, $disk);

// Generate and return image as response
$image->toResponse($code, $headers);

// Generate and return image as base64 string
$image->toBase64($code, $headers);

If any of the methods will be used without generate() one, an image will be generated with default params.

You can provide your own parameters for generating image:

  • $dimensions - image dimensions.
    You can provide as dimensions image size and/or ratio. By default used '800x600'.
    Examples:
    '800x600' will generate an image with width 800px and height 600px
    '800' will generate an image with 800px width and height
    '250x1:2' will generate an image with 250px width and 500px height
    '1:3x300' will generate an image with width 100px and height 300px
  • $format - generated image format ('jpg', 'gif', 'png'). Default format is 'png'.
  • $bg-color - image background color in hex. Default is white ('ffffff').
  • $fg_color - image text color in hex. Default is black ('000000').
  • $text variable provides text that will be written on the image. Default is image dimensions.

Resources

License

The MIT License (MIT).

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-08-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固