Skip to content

Commit

Permalink
Merge pull request #9 from joseluisq/v3.0
Browse files Browse the repository at this point in the history
v3.0.0
  • Loading branch information
joseluisq authored Feb 16, 2017
2 parents 93b044c + d87534b commit 36eba16
Show file tree
Hide file tree
Showing 21 changed files with 2,229 additions and 313 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ examples/*.gif
tmp/
.tmp/
composer.phar
composer.lock
composer-test.lock
build/artifacts/
artifacts/
docs/_build
docs/*.pyc
*.log
.idea
.DS_STORE
.DS_Store
35 changes: 22 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,28 @@ sudo: false
language: php

php:
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm

matrix:
allow_failures:
- php: hhvm

fast_finish: true

install: travis_retry composer install --no-interaction --prefer-source
- 7.0
- 7.0snapshot
- 7.1
- 7.1snapshot
- master

cache:
directories:
- $HOME/.composer/cache/files

env:
matrix:
- DEPENDENCIES="high"
- DEPENDENCIES="low"

before_install:
- composer self-update
- composer clear-cache

install:
- if [[ "$DEPENDENCIES" = 'high' ]]; then travis_retry composer update --no-interaction --no-ansi --no-progress --no-suggest --optimize-autoloader --prefer-stable; fi
- if [[ "$DEPENDENCIES" = 'low' ]]; then travis_retry composer update --no-interaction --no-ansi --no-progress --no-suggest --optimize-autoloader --prefer-stable --prefer-lowest; fi

script: make test

Expand Down
88 changes: 88 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Change Log
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
- Feature: `isEllipse()` method support in `Figure` for create ellipses.
- Feature: `isRectangle()` method support in `Figure` for create rectangles.
- `CHANGELOG.md` file.

### Changed
- `Figure` elements are `PNG` by default.
- Support for `PHP >= 7.0.x` only.
- Update PHPUnit 6.0.
- Update test suite.
- Update README.md.
- Update LICENSE.md.
- Preserve `composer.lock` files.
- Codebase with doc-comments.
- Codebase more standard: `phpcs ./src --standard=PSR2` and `phpcbf -w ./src --standard=PSR2`

### Fixed
- Better support for `Figure` elements with opacity. (0 to 127)
- Better support for `$image->load(..)` method when load image from path or URL.

### Removed
- Guzzle dependency removed.

### Deprecated
- GImage is no longer supported on `PHP <= 5.5`

## [2.0.1] - 2016-10-20
### Changed
- Codebase PSR-2 standard.

### Fixed
- Minor travis fixes.

## [2.0.0] - 2016-09-29
### Added
- Codebase with new syntax and namespaces.
- Codebase are now namespaced (`\GImage`).
- Sources clases was renamed to `Image`, `Figure`, `Text`, `Canvas` and `Utils`.

### Changed
- Make file tests.
- Travis with PHP `7.0` and `7.1`.
- Support for `PHP >= 5.5`

### Removed
- Cleanup some files.

### Deprecated
- GImage is no longer supported on `PHP <= 5.3`

## [1.5.2] - 2016-07-20
### Added
- Composer suggest package.

### Changed
- Examples updated.

## [1.5.1] - 2016-01-12
### Added
- Support line-height for `GText` class.
Example:
```php
<?php
$text = new GText('Lorem ipsum');
$text->setLineHeight(1.2);
```
- Composer support.
- API docs.
- Composer badges.

## [1.5.0] - 2015-11-15
### Added
- Initial commit.
- PHP `5.3` support.

[Unreleased]: https://github.com/joseluisq/gimage/compare/v2.0.1...HEAD
[2.0.1]: https://github.com/joseluisq/gimage/compare/v2.0.0...v2.0.1
[2.0.0]: https://github.com/joseluisq/gimage/compare/v1.5.2...v2.0.0
[1.5.2]: https://github.com/joseluisq/gimage/compare/v1.5.1...v1.5.2
[1.5.1]: https://github.com/joseluisq/gimage/compare/v1.5.0...v1.5.1
[1.5.0]: https://github.com/joseluisq/gimage/tree/1.5.0
2 changes: 1 addition & 1 deletion license.md → LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2016 José Luis Quintana <git.io/joseluisq>
Copyright (c) 2017 José Luis Quintana <git.io/joseluisq>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
114 changes: 84 additions & 30 deletions readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,25 @@

[![Build Status](https://travis-ci.org/joseluisq/gimage.svg?branch=master)](https://travis-ci.org/joseluisq/gimage) [![Latest Stable Version](https://poser.pugx.org/joseluisq/gimage/version)](https://packagist.org/packages/joseluisq/gimage) [![Latest Unstable Version](https://poser.pugx.org/joseluisq/gimage/v/unstable)](//packagist.org/packages/joseluisq/gimage) [![Total Downloads](https://poser.pugx.org/joseluisq/gimage/downloads)](https://packagist.org/packages/joseluisq/gimage) [![License](https://poser.pugx.org/joseluisq/gimage/license)](https://packagist.org/packages/joseluisq/gimage)

> A simple PHP library for easy image handling.
GImage is a simple extended library based on [PHP Image Processing and GD](http://php.net/manual/en/book.image.php) for easy image handling. With GImage you can read, create, crop, resize, rotate, embed text, merge and save your JPG or PNG images easy. GImage require **PHP 5.5** or later and [GD Extension](http://php.net/manual/en/book.image.php).
> A PHP library for easy image handling.
![A simple presentation card with GImage](https://cloud.githubusercontent.com/assets/1700322/18941713/eed7fa34-85d8-11e6-8033-bf787e4aa236.png)

[*View sample code*](#creating-a-simple-presentation-card)
_* Presentation card - [view sample code](#creating-a-simple-presentation-card)_

__GImage__ is a simple extended library based on [PHP Image Processing and GD](http://php.net/manual/en/book.image.php) for processing images without stress. For example:
- Load a image from local path or URL.
- Create figures like a rectangles or ellipses with opacity.
- Rotate and crop (proportionally).
- Resize and scale proportionally.
- Embed text with custom TTF fonts.
- Compose a pool of images with Canvas.
- Swap image formats like JPG, PNG and GIF.
- Save file or output on browser.
- Save several copies of an image.

## Requirements
GImage requires **[PHP 7.x](http://php.net/manual/en/migration70.new-features.php)** and latest [GD Extension](http://php.net/manual/en/book.image.php).

## Install

Expand All @@ -18,9 +30,11 @@ composer require joseluisq/gimage

## Usage

### Basic
For more examples check out the [./examples](./examples) dir.

Working with external JPG image and output on browser as PNG format.
#### Image

Working with an external JPG image and output it on browser as PNG format:

```php
<?php
Expand All @@ -45,28 +59,66 @@ $avatar
->output();
```

### Using a Figure
#### Figure

Creating a simple green rectangle.
Creating a green ellipse:

```php
<?php

use GImage\Figure;

// Setting rectangle sizes
$rectangle = new Figure(500, 300);
$rectangle
// Setting a green background color
// Setting ellipse sizes
$ellipse = new Figure(500, 300);
$ellipse
// Set ellipse type
->isEllipse()
// Setting a green RGB color
->setBackgroundColor(170, 188, 147)
// Creating the figure
->create()
// Outputting JPG image (by default) on the browser.
// Outputting image (PNG Figure by default) on the browser.
->output();
```

### Creating a simple presentation card
Creating a simple presentation card with Image, Canvas, Figure and GText.
#### Text

Creating a rectangle with Text embedded:

```php
<?php

use GImage\Text;
use GImage\Figure;
use GImage\Canvas;

$figure = new Figure(400, 250);
$figure
->isRectangle()
->setBackgroundColor(47, 42, 39)
->create();

$text = new Text('My awesome text!');
$text
->setWidth(400)
->setHeight(250)
->setLineHeight(1.2)
->setAlign('center')
->setValign('center')
->setSize(22)
->setColor(255, 255, 255)
->setFontface('./fonts/Lato-Bol.ttf');

$canvas = new Canvas($figure);
$canvas
->append($text)
->toPNG()
->draw()
->save('./text.png');
```

#### Creating a simple presentation card
Presentation card example using `Image`, `Canvas`, `Figure` and `Text`.

```php
<?php
Expand All @@ -76,13 +128,13 @@ use GImage\Text;
use GImage\Figure;
use GImage\Canvas;

$avatar_image = new GImage();
$avatar_image = new Image();
$avatar_image
->load('http://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?s=100.jpg')
->setTop(60)
->setLeft(70);

$about_text = new GText("MY AWESOME PRESENTATION CARD GENERATED WITH GIMAGE");
$about_text = new Text("MY AWESOME PRESENTATION CARD GENERATED WITH GIMAGE");
$about_text
->setSize(16)
->setWidth(300)
Expand All @@ -91,7 +143,7 @@ $about_text
->setColor(204, 164, 116)
->setFontface('fonts/Lato-Light.ttf');

$twitter_text = new GText('@username');
$twitter_text = new Text('@username');
$twitter_text
->setSize(11)
->setWidth(70)
Expand All @@ -100,47 +152,46 @@ $twitter_text
->setColor(130, 127, 125)
->setFontface('fonts/Lato-Regular.ttf');

$canvas_figure = new GFigure(550, 250);
$canvas_figure = new Figure(550, 250);
$canvas_figure
->setBackgroundColor(47, 42, 39)
->create();

$avatar_box = new GFigure($avatar_image->getWidth() + 16, $avatar_image
$avatar_box = new Figure($avatar_image->getWidth() + 16, $avatar_image
->getHeight() + 17);
$avatar_box
->setBackgroundColor(63, 56, 52)
->setLeft($avatar_image->getLeft() - 7)
->setTop($avatar_image->getTop() - 8)
->create();

$avatar_box2 = new GFigure($avatar_image->getWidth() + 3, $avatar_image
$avatar_box2 = new Figure($avatar_image->getWidth() + 3, $avatar_image
->getHeight() + 19);
$avatar_box2
->setBackgroundColor(79, 72, 67)
->setLeft($avatar_image->getLeft() + 7)
->setTop($avatar_image->getTop() - 9)
->create();

$avatar_box3 = new GFigure(120, 240);
$avatar_box3 = new Figure(120, 240);
$avatar_box3
->setBackgroundColor(63, 56, 52)
->create();

$line_vertical = new GFigure(600, 10);
$line_vertical = new Figure(600, 10);
$line_vertical
->setBackgroundColor(119, 99, 77)
->setTop(240)
->create();

$line_horizontal = new GFigure(1, 240);
$line_horizontal = new Figure(1, 240);
$line_horizontal
->setBackgroundColor(79, 72, 67)
->setLeft(120)
->create();

$canvas = new GCanvas();
$canvas = new Canvas($canvas_figure);
$canvas
->from($canvas_figure)
->append([
$line_horizontal,
$avatar_box2,
Expand All @@ -153,16 +204,19 @@ $canvas
])
->toPNG()
->draw()
->save('card.png');
->save('./card.png');
```

## Contribution
If you would like to contribute [pull requests](https://github.com/joseluisq/gimage/pulls) and [issues](https://github.com/joseluisq/gimage/issues) will be welcome! Feature requests are welcome. Please before sending some feature requests make sure provide as much detail and context as possible.
## Changelog
Check out the [CHANGELOG.md](./CHANGELOG.md) file.

## Documentation
Read [API Documentation](http://joseluisq.github.io/gimage/#documentation)

## Contribution
If you would like to contribute [pull requests](https://github.com/joseluisq/gimage/pulls) and [issues](https://github.com/joseluisq/gimage/issues) will be welcome! Feature requests are welcome. Please before sending some feature requests make sure provide as much detail and context as possible.

## License
MIT license

© 2016 [José Luis Quintana](https://git.io/joseluisq)
© 2017 [José Luis Quintana](https://git.io/joseluisq)
Loading

0 comments on commit 36eba16

Please sign in to comment.