Giter Club home page Giter Club logo

imageresize's Introduction

PHP ImageResize Library

What is it

A library implemented by PHP to resize image smartly and add water mark.

This library will help you resize the image according to the width and height defined and cut smartly to promise the length-to-width ratio, and add water mark in the mean time.

Requirements

  • PHP 5 +
  • PHP GD
  • composer

Please assure that you have installed php-gd, and install it via apt install php7.0-gd or apt install php5-gd is recommended.

Installation

Here are two ways to install:

  • Using composer:

    composer require php-quickorm/image-resize
    
  • or download the ImageResize.php to your project and import it by require "ImageResize.php";

Usage

Resize

// Resize the firework.jpg to 800x600
$a = new ImageResize(realpath('firework.jpg'),800,600);

// Save to firework2.png;
$a->save("firework.png");

// or send as HTTP response
$a->render();

Water Mark

// Resize the firework.jpg to 800x600
$a = new ImageResize(realpath('firework.jpg'),800,600);

/*
* Add text to image
* The font size is 1 - 5 and the position only supports bottom-left, bottom-right, top-left, top-right 
*/

// use font size 5, color #ffffff and place at bottom-right with margin 10px
$a->addTextMark("Author:Rytia", 5, "#ffffff", "right", "bottom",10);
// use font size 4, color #ccccc and place at bottom-left with margin 15px
$a->addTextMark("Blog:www.zzfly.net", 4, "#cccccc", "left", "bottom",15);


/*
* Add water mark to image
* The position only supports bottom-left, bottom-right, top-left, top-right 
*/
$a->addImageMark(realpath('mark.jpg'),100,80,"right","bottom",50);

// Save to firework2.png;
$a->save("firework.png");

// or send as HTTP response
$a->render();

img

imageresize's People

Contributors

zzfly256 avatar

Stargazers

 avatar

Watchers

 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.