GithubHelp home page GithubHelp logo

rahi-cube / extensions Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 116 KB

File Extensions Provide a simple way to generate any file icon so that you don't to download icon each extension type.

PHP 100.00%

extensions's Introduction

File Extensions

Provide a simple way to generate any file icon so that you don't to download icon each extension type.

Install

composer require "gavande/extensions"

Usage

Generate a extension icon

$icon = new Extensions\FileExtension();

$icon->generate('png', 40)->saveAsPng('/path/to/file.png');

# If you don't specify a size, the max size will be used (240 by default)	 			

Custom font

The font used by default is Open Sans Regular from google font. If you want, you can use any TTF font by setting the font file full path like so :

$icon->setFontFile('path/to/ttf_file.ttf')
    ->generate('png', 40)
    ->saveAsPng('/path/to/file.png');

Save as jpeg

$icon->generate('png')
    ->saveAsJpeg('/path/to/file.jpg');	

Save as png

$icon->generate('png')
    ->saveAsPng('/path/to/file.png');	

Text color

$icon->setTextColor([255, 0, 0])
    ->generate('png')
    ->saveAsJpeg('/path/to/file.jpg');	

Text shadow

$icon
    ->setTextColor([255, 0, 0])
    ->generate('png')
    ->showTextShadow(false)
    ->saveAsJpeg('/path/to/file.jpg');	

Background colors palette

$icon
    ->setBackgroundColors([[255, 0, 0], [0, 255, 0], [0, 0, 255]])
    ->generate('png')
    ->saveAsJpeg('/path/to/file.jpg');

Using the same background color

You can chain multiple generation to keep the same background color. (Generating multiple sizes)

$icon
    ->generate('png', 50)->saveAsJpeg('/path/to/50x50/file.jpg')
    ->generate('png', 100)->saveAsJpeg('/path/to/100x100/file.jpg');

Reset background color

If you want you can reset background color (so that a new random one will be used) in the middle of chaining

$icon
    ->generate('png', 50)->saveAsJpeg('/path/to/50x50/file.jpg')
    ->generate('png', 100)->saveAsJpeg('/path/to/100x100/file.jpg')
    ->resetBackgroundColor()
    ->generate('png', 100)->saveAsJpeg('/path/to/100x100/file.jpg');

extensions's People

Contributors

rahi-cube avatar

Watchers

James Cloos avatar  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.