Giter Site home page Giter Site logo

imaged's Introduction

Imaged

Imaged is object-oriented wrapper for GD2 library.

It addresses a few issues while working with GD2, e.g. format auto-detecting (both when reading and writing), easy and flexible resizing and cropping etc.

Methods

  • static create(file)
  • __construct(file)
  • resample(w, h, [srcX], [srcY], [scrW], [srcH])
  • crop(w, h, [x], [y])
  • fit(w, h, [method])
  • write([filename], [args])
  • write([type], [args])
  • __call(method, [args])

Example

Following example reads source PNG file, then fits it into max 300x300 square, crops sides outside 200x200 square and writes it as JPG file.

    Imaged::create('source.png')
		->fit(300, 300)
        ->crop(200, 200, Imaged::CENTER, Imaged::CENTER)
        ->write('target.jpg');

Supported formats

Imaged supports most popular web formats, which are JPEG, PNG and GIF. There is no plan for other formats supported by GD (XPM, XBM, WBMP, GD, GD2 are either not widely used or simply old).

Exceptions codes

  • Loading/saving image
    • 11 Provided file does not exist or is not an image
    • 12 Unsupported image type (while reading)
    • 13 Unsupported image type (while writing)
  • Operations
    • 21 Operation failed - {func}() returned false
    • 22 Resampling failed - imagecopyresampled() returned false
    • 23 Unsupported method Imaged::{method}()
  • Sizes
    • 31 Either width or height must be set
    • 32 Both new width and new height must be greather than 0

imaged's People

Contributors

sobstel avatar

Stargazers

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