ghero/laravel-dominant-color 问题修复 & 功能扩展

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

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

ghero/laravel-dominant-color

Composer 安装命令:

composer require ghero/laravel-dominant-color

包简介

A package that generates a base64 encoded GIF with the dominant color of the given image (for lazy loading use)

README 文档

README

A package that generates a base64 encoded GIF with the dominant color of the given image (for lazy loading use)

Requires the php Imagik library to work!

Installation

Require the package via composer

composer require ghero/laravel-dominant-color

Include the service provider within your providers in config/app.php.

'providers' => [
    ...
    Ghero\DominantColor\DominantColorServiceProvider::class,
    ...    
];

Next, add the class alias to the aliases array of config/app.php.

'aliases' => [
    ...
    'DominantColor' => Ghero\DominantColor\Facades\DominantColor::class,
    ...    
];

Usage

Simply call DominantColor::create($file); passing a valid url to an Image or an Imagick instance

this will generate a string with the base 64 encoded 1x1 GIF (ex. data:image/gif;base64,R0lGODlhAQABAIABAI2JggAAACwAAAAAAQABAAACAkQBADs=) The GIF is only 1 color, the dominant color of the image

You can then easily set this string as src attribute specifing the desired width and height:

<img src='data:image/gif;base64,R0lGODlhAQABAIABAI2JggAAACwAAAAAAQABAAACAkQBADs=' width='200' height='200'/>

Other available methods

Get the color

You can also get just the hex code of the dominant color using $color = DominantColor::setColor($file)->getColor(); The default output will be a plain hex code without the starting "#". You can customize the output passing an optional parameter to the getColor method: Available outputs:

  • "hex": outputs complete hex code (ex. #FFFFFF)
  • "rgb": outputs Rgb format string (ex. 255,255,255)
  • "array": outputs Rgb format as an array (ex. ['r' => 255, 'g' => 255, 'b' => 255])

Get the GIF

To get the base 64 encoded GIF from an hex code, just use $gif = DominantColor::setGif($color)->getGif().

Todo

  • Add GD and Gmagick support

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固