Giter VIP home page Giter VIP logo

kirby-dominant-color's Introduction

Extract an Image's dominant color - Kirby CMS Panel

Screenshot

Simple kirby panel hook that will extract the most dominant color for a given image and store it in the file's metadata on the color field as an hex value eg: #fefefe.

This is useful for example when lazyloading images, Google uses the same technique in Google Images.

The hook will fire for any image you upload or replace in the panel.

Installation

git submodule add [email protected]:iandoe/kirby-dominant-color.git site/plugins/dominantcolor

then run composer in the resulting directory

cd site/plugins/dominantcolor/
composer install

Diplaying the value in the panel field

Combined with https://github.com/ian-cox/Kirby-Color-Picker You can have the extracted color displayed in the panel when looking at the image your blueprint's file fields :

files:
  fields:
    color:
      label: Dominant Color
      type: color

Using the value

The value will be available on the image object like such :

<?php $page->image('myimage.jpg')->color() ?>

License

MIT

Credits

All credits goes to @thephpleague for the actual color extracting process in PHP https://github.com/thephpleague/color-extractor

kirby-dominant-color's People

Contributors

iandoe avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.