PHPackages                             acoustep/canvas - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. acoustep/canvas

ActiveLibrary[Image &amp; Media](/categories/media)

acoustep/canvas
===============

Simple GD Library class for resizing images

v0.1(13y ago)0835MITPHPPHP &gt;=5.3.0

Since Jun 22Pushed 13y agoCompare

[ Source](https://github.com/acoustep/Canvas)[ Packagist](https://packagist.org/packages/acoustep/canvas)[ Docs](http://github.com/acoustep/canvas)[ RSS](/packages/acoustep-canvas/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (2)Used By (0)

Canvas
======

[](#canvas)

Canvas is a simple PHP class for creating and manipulating image sizes with the GD Library.

Usage
-----

[](#usage)

### Setting up the canvas

[](#setting-up-the-canvas)

There are two ways to set up the canvas.

1. Through the constructor

```
$canvas = \Acoustep\Canvas(500, 250, '#000000');

```

2. Through methods

```
$canvas = \Acoustep\Canvas()->width(500)->height(250)->background('#000000');

```

### Adding images

[](#adding-images)

Images are added through the image method, you can add as many layers as you would like.

The first image added will be added to the bottom of the output. The rest will be layered on top of each other in the order they were added.

The image method takes two arguments: A string (The file along with the path to the file) and an array of arguments.

```
$canvas = \Acoustep\Canvas()->width(500)
							->height(250)
							->background('#000000')
							->image('images/test.jpg', array('x' => 'left',
											                 'y' => 'top',
											                 'scale' => 'best'));

```

X can be an integer which is the offset from the canvas in pixels or **left**, **centre** or **right**.

Y can also be an integer for a specific offset, **top**, **middle** or **bottom**

Scale can be **width**, **height**, **best** or **false**.

- Width sets the image to fit best with the canvas width.
- Height sets the image to fit best with the canvas height.
- Best will try to figure out whether to use width or height for you.
- False will keep the image size the same as it was originally.

### Outputting the image

[](#outputting-the-image)

There are three methods to output the image to the user. `output()`, `filetype()` and `create()`.

- Filetype lets you set the image type. PNG, GIF and JPG are supported.
- Output lets you specify a filename to output the image to. If `NULL` it will try to output to the current file - You will need to set the headers appropriately for it.
- Create is used when you are ready to output the image to the user. This method is always called last.

Examples
--------

[](#examples)

### Output to a file named 'output.png'

[](#output-to-a-file-named-outputpng)

```
$canvas = \Acoustep\Canvas()->width(500)
							->height(250)
							->background('#000000')
							->image('images/test.jpg', array('x' => 'left',
											                 'y' => 'top',
											                 'scale' => 'best'))
							->filetype('png')
							->output('output')
							->create();

```

### Output to the current page

[](#output-to-the-current-page)

```
header("Content-Type: image/png");
$canvas = \Acoustep\Canvas()->width(500)
							->height(250)
							->background('#000000')
							->image('images/test.jpg', array('x' => 'center',
											                 'y' => 'middle',
											                 'scale' => 'width'))
							->filetype('png')
							->output(NULL)
							->create();

```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4757d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2813287?v=4)[Mitch](/maintainers/acoustep)[@acoustep](https://github.com/acoustep)

---

Top Contributors

[![acoustep](https://avatars.githubusercontent.com/u/2813287?v=4)](https://github.com/acoustep "acoustep (16 commits)")

---

Tags

imagescanvasgd libraryacoustep

### Embed Badge

![Health badge](/badges/acoustep-canvas/health.svg)

```
[![Health](https://phpackages.com/badges/acoustep-canvas/health.svg)](https://phpackages.com/packages/acoustep-canvas)
```

###  Alternatives

[imsky/holder

Client-side image placeholders.

5.8k20.6k2](/packages/imsky-holder)[rosell-dk/webp-convert

Convert JPEG &amp; PNG to WebP with PHP

6049.0M59](/packages/rosell-dk-webp-convert)[jbzoo/image

A PHP class that simplifies working with images

174129.4k3](/packages/jbzoo-image)[mmo/faker-images

Different images provider for Faker

56403.1k7](/packages/mmo-faker-images)[mindkomm/timmy

Advanced image manipulation for Timber.

17737.1k](/packages/mindkomm-timmy)[wp-media/imagify-plugin

Image optimization plugin for WordPress by WP Media.

8067.5k](/packages/wp-media-imagify-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
